« first day (1300 days earlier)      last day (3665 days later) » 

12:02 AM
Ok, i wrote a .pyx that inherits from a class that was pre-compiled into a .pyd when the package installed on my (Windows) machine ,right?
If this were python, all i would need to do is...
from Foo import Bar

class Baz(Bar):
    pass
...and we'd be good to go.
If i was dealing with Foo.pxd/.pyx, it'd be no problem. But i have Foo.pyd (or .so for you linux users). How do i adapt to this scenario?
@AppleDroid: Did i lose you?
 
if you are on windows and want to run linux commands then you need to install MinGW
 
No, forget the linux. That's not the issue.
 
so you need to run the .pyd file
 
I just want to know how to make a cython extension that imports from a .pyd. I believe they are to be treated as libraires, but how do you work with pre-compiled libraries in cython?
 
sry not much idea about cython
try google
 
12:11 AM
I'll just ask on SO proper.
Thanks anyways.
 
12:59 AM
def myprin1(a):
def myprin2():
print a
return
return

myprin1('Hi')
Sorry about that. How to format code in chat?
 
Click "Fixed width.."
 
I can't see the button fixed width.
 
If you have a multiline message you should
Like
This
import se.diamond
me.add(se.diamond.new())
 
Found it!
Finally I can ask my question:
@TheDoctor
Thanks!
def myprin1(a):
    def myprin2():
        print a
        return
    return

myprin1('Hi')
Why is my code not printing 'Hi'?
Is the variable 'a' not visible to the nested function myprin2?
 
It just defines myprin2, not calling it
 
1:13 AM
Damn! That was stupid....
@TheDoctor Thanks again!
 
Such welcome
 
Where can I read about the namespace visibility? I am referring to it correctly or is it called something else by programmers?
*Am I
 
My bad.. that was one Google away... was just wondering if I had the right term...
 
1:37 AM
 function=self.select_treeview.insert("",'end',values=("",_(u"Element"),tag=tags[0]))
                                                                              ^
SyntaxError: invalid syntax
why
 
tag=tags[0] is inside the tuple containing _(u"Element")
function=self.select_treeview.insert("",'end',values=("",_(u"Element")),tag=tags[0])
Should work
 
thank you so much
I should focus harder instead of trying to find an error in the hundreds of lines before
 
zmo
1:54 AM
cbg!
it's been a while I did not come around here :-)
 
what have you done in Python ?
It s the first time I come here
 
zmo
though I won't stay around for long, as it's late and I'm begining to crack down
 
I had to anwer a question to have enough reputation
 
zmo
@WalleCyril, well I've written in python an application that enables me to talk to you without using the chat interface :-)
and I'm pretty sure I'm the only one to use it to chat on SO, as it's pretty buggy :-p
 
oh
via which interface ?
do you use tkinter ?
 
zmo
1:58 AM
IRC
 
But how do you access IRC ?
Sorry I m born after the glory of IRC
 
zmo
I've written a gateway that exposes a SO chat as an IRC server
 
That's intersting
 
zmo
it's on my github if you're curious
anyway
 
does it transform the irc protocol into HTTP POST ?
 
zmo
2:05 AM
yup
 
is moron a religion ?
if yes why did you write
if you do fork and make this work better and do not tell me, you're just a moron
in readme file
 
zmo
nope
mormons is a religion
 
and what does moron mean ?
 
zmo
morons are just… abrutis
 
ah
that explains everything
I see that you use import twisted ? Where does it come from
 
zmo
2:12 AM
pip install twisted
where do you think it can come from ? :)
is it me, or the questions are worst everyday?!
I'm even being upvoted whereas I'm being sarcastic in my answer
 
sorry I m new , and what does pip do ?
but you were right
 
Python Index of Packages
Package manager
 
I just downloaded Python and got all packages
Does Pip give you more ?
 
Yep
 
zmo
@WalleCyril, pypi.python.org/pypi
 
2:15 AM
Then I should have a look at Pip,
 
zmo
if you don't have it on your command line, you can install it using easy_install pip
ok, I'm really tired now
rbrb @Thedoctor & @WalleCyril o/
 
Night
 
how to check given string is Url or not ?
 
@AppleDroid: Could you rephrase?
 
Sounds like a good PPCG question...
 
2:44 AM
this might help you
source world wide web consortioum w3.com
w3.org
*
 
 
2 hours later…
5:14 AM
cbg
 
@Jerry cbg :)
 
potato @thefourtheye?
 
@Jerry Banana :)
Wow, I didn't have to refer the salad book :)
 
haha, it takes a while, but when you get it, it's hard to forget =P
 
Too much power :(
39
Q: Increase close vote weight for gold tag badge holders

Travis JIn order to increase the efficiency with which poor quality questions are closed, it could make sense to have weighted close votes for a small subset of qualified users. A very good way to measure the qualified users would be to leverage the tag badges. However, it needs to be rationally limite...

 
 
2 hours later…
7:00 AM
@thefourtheye did you get it running yet
 
7:21 AM
Hi all. I know that Python doesn't require that variables be declared before usage, and that's consistent with other scripting languages I've used. However, because I have some Java/C# training, I'm still pretty much in the habit of assigning "self.variable = None" at the top of a class for any classwide variables I use (or just "variable = None" if at the top level). It's a little bizarre becaue I don't see what object type they're eventually going to hold, but I put that in a comment...
Is this considered decent Pythonic practice, or am I shoehorning in ill-fitting ways of thinking from other languages?
@Kevin Kevin, This makes sense to me and was my original idea, and while it's true that I thought the idea of using a mutable class object with changed attributes could allow for a nice template for instantiations when referring to the same object was desirable, I now see that it makes things less flexible unless the class is designed explicitly for one and only one instantiation in every conceivable application; it also reduces clarity when objects are instantiated.
@AnttiHaapala I think I haven't fully wrapped my brain designing for Python modules yet; I've been so in the habit of writing self-contained Bash scripts or AppleScripts over the past few years that I once again need to get used to the idea of subdividing functionality across files.
 
@IvanX then there is the question of why these variables are uninitialized? :D
 
Because I'm "declaring" them for future visibility when I initialize them further down the code.
So I know what classwide variables I'm using in a given class at one glance.
 
7:39 AM
@thefourtheye the experiment with being able to binding vote as duplicate will be interesting though...
 
I think it'll reduce the number of dupe votes cast as people will make sure they're true duplicates
Which is neither good nor bad, will have to see how it works out
 
Means we'll need to make sure our canonical dupes stays up to date
 
For some questions we've got more than one dupe, we should pick the one and make sure that is top. Keep others there for reference of course
 
Indeed :p
 
Oh and Briiiiiiiiiiiiiiian!
 
7:47 AM
Oh yeah...... STEWIE!!!!!!!!!!!!! Sorry - haven't gotten around to grabbing my tea yet
 
8:41 AM
@AnttiHaapala Nope :-( Busy with work, I think for the whole week I ll be busy with that I guess... Sorry.
@JonClements Yup, we may have to strengthen our Common Questions list
 
what does type " module " mean?
 
cabbage everybody
 
xavier after so many days
cbg
this looks good
 
9:02 AM
I am so busy at work, barely any time to cbg anymore.
 
9:41 AM
cbg all
 
9:51 AM
cabbage @Caffeine
 
zmo
cbg
 
10:32 AM
@Inbar join the club :)
@Inbar of course, I'm assuming that's the "greeting form" of cbg - rather than a place holder for sleep, eat, take toilet breaks etc... :p
 
cbg
 
@Peter cbg!
 
cbg @PeterVaro
 
@JonClementswhat happened with the "meeting"? It used to be on yesterday, right?
 
Yesterday or today... yeah
 
10:39 AM
oh, okay, then :)
@AnttiHaapala the video you've posted yesterday was awesome (about the meetings)!
 
I really enjoyed it :)
 
Answering questions!? Jon!? Never!
 
zmo
saying stupid things? me? never! O;-)
 
Umm... just had a power cut and the door bell rang...
no one at the door
Thought it was bloody bad timing for someone to turn up
get back up upstairs, door bell rings again
No one at the door... but it was the same time the power came back on
I didn't realise the door bell notified about such things... must remember that :)
Ummm.... @thefourtheye I think that answer is wrong :)
 
10:57 AM
cbg all
 
cbg @tilaprimera - potato?
 
@JonClements banana
:D
>> a
array([[1, 2, 3],
[4, 5, 6]])
>>> c
array([7, 8, 9])
>>> a+c
array([[ 8, 10, 12],
[11, 13, 15]])
see this, a.shape is (2,3) but shape of c is (3,) how?
@JonClements potato?
 
c gets broadcast
 
potato everyone?
i get the thing about broadcast
the part about shape is what i dont understand
shape attribute returns the tuple defining the rank (the length of the tuple) and the length of each axis (the values in the tuple).
 
But a (3,) can be applied to each element of a (2, 3)... the 3 matches
 
11:01 AM
what is 3 in (3,) and 3 in (2,3) ?
 
(3,) is a singular array of length 3
(2, 3) is a 2D array with 2 rows each with 3 columns
 
thank you
 
Since they're compatible, then the theory is you want to add the "columns" from the length 3, to each row in the other one
Not sure I've described that as well I should, but gave it a go :)
 
i understand the broadcast theory but i got confused the way shape was presented for the two arrays.
 
Wow, 23 chat flags.... mostly appear to be in a private room :)
 
11:06 AM
what are chat flags?
 
Like on the main site, people in chat can flag messages as spam/offensive etc...
 
where can we see the flags?
 
Cbg everyone :)
 
cbg @sa
 
Is it possible t have a counter in a recursive function?
 
11:12 AM
heya @Reblochon
 
@JonClements How can I get a count to work in my recursion?
 
The first page of "python recursive counting" seems very promising... did you bother trying something like that? :)
 
Yep
But it;s not really working
let me paste my code
 
bangs head on table :)
 
11:19 AM
What solutions did you try?
 
for some reason, I'm getting this as well: .IndexError: string index out of range
I tried to make another function to keep track of the count
 
Where's that example then?
 
Let me put it :P
 
You do realise the top 3 search results are SO entries and about how to count substrings specifically?
How about
3
Q: Counting recursion in a python program!

Mojo_JojoI need to count the number of times recursion in a python program. So basically I need a static variable kind of thing (like in C) which can count the number of times the function is called.

That's probably the simplest to grasp how to put a counter in and use it
And did you look at the line you're getting the IndexError....
 
Yup
 
11:23 AM
If you're on the last character already, what do you expect word[1] to do ?
 
word[1:] is giving the error
I checked if it's true
 
That won't work though... because you're trying to access it
 
hence your error
Just try 'x'[1] for instance...
 
I used len(word)> 1
 
11:26 AM
What are you trying to do there anyway?
 
Trying to find out the number of pair characters in a string
example in hello we have ll,so 1 pair
hello jimmy has ll and mm so 2 pairs
I'm trying to fix the counter now
 
What does helllo have ?
 
1 pair
hellllo has 2 pairs
 
Greetings
 
heya @MrE!
 
11:32 AM
Hey @JonClements!
Just wanted to vent about this question stackoverflow.com/q/23537510/553404 I mean how can you type out a load of code and not even check that it runs! aaaaagh
"It should run"...
 
Well, I think your comment makes the point clearly and politely
 
Hopefully so, yes
 
Greeting and Salutations Mr S
 
Progress
 
I see a picture now and a couple of fixes :)
 
11:41 AM
@IvanX I usually see variables declared only when they're needed, and no earlier. I can think of two reasons why this might be preferable. 1. It's less code. 2. It guards against a class of logic errors where you attempt to access a variable before it is declared.
 
doing should_preserve_file = None at the start of your script, if you mistakenly put if not should_preserve_file: delete_file() before the variable gets given a meaningful value, Python will cheerfully delete your valuable file; if you never did should_preserve_file = None, you would get a NameError or AttribtueError, informing you of your mistake, and your file would be safe.
 
I wonder why it's not working
 
Yes...now to try and figure out what is actually being asked...
 
@Sab don't make us ask every time what "it's not working" means... :)
 
11:42 AM
@JonClements I was typing the explanation, give me time :)
So yea. I don't get an output. It's just blank
 
@Sab in that case..... just type the explanation... what's the point of just saying "I wonder why it's not working"... :)
 
:P I guess I should stop thinking out loud :D
 
What do you expect it to print?
 
I expect it to print 1
The program is to find pair of characters
Example: Hello has ll so 1 pair
Helllo still has 1 pair
But Helllloo has 3 pairs
Hello Jimmy has 2 pairs
 
Well, here's how it works now: it takes the if branch because "hello" has a length longer than one. It skips the second if because "h" doesn't equal "e". Then the program ends, printing nothing and returning nothing
 
11:45 AM
@Sab why are you doing this recusively anyway? I'm assuming that you have to
 
Ya I have to
it's an assignment
But I don't really care about the assignment, I care about understanding where I'm wrong
I see where I'm wrong now @Kevin pointed it out.
 
As usual, the teacher does a great disservice to the student by making him use recursion in a context where it's useless
 
Off to lunch, have a good day all
 
@MrE good to see you around... - enjoy your lunch
 
11:47 AM
:)
 
Had I my way, every introduction to recursion would start with trees. Tree classes are bursting at the seams with opportunities to use recursion.
 
... that are actually useful :)
Why is counting character pairs so common?
 
Of course, then students would have to wait until they learned about classes before learning about recursion. I'm fine with that, though
 
@Kevin it definitely gets taught too early for my liking
 
I really want to make my L-system using recursion :D
@JonClements It gets taught in roughly 2-3 lectures tops (so in less than 3 hours)
 
11:49 AM
I know a lot of students struggle with the concept... Maybe they learn it too early. Haven't yet developed the mental tools necessary to visualize it
 
I fixed my function now it's printing 4 for the case of Hellllo jimmy
heh
I guess the llll together makes it bad
 
yep, llll has three pairs - the first two, the last two, and the middle two
 
So it's logical I guess then
So it works :3
 
It doesn't fit your original specs, though. You say "Helllo" has one pair, but I predict your function will tell you it has two
 
I see where I was wrong. I should have had an else statement to prevent it from ending and printing nothing
 
11:52 AM
@Kevin umm.... I think I could live with that approach... recursion as part of data structures actually makes sense and by that stage hopefully grasping more... and then at least you're not trying to work out why your recursive algorithm doesn't count characters currently and wondering why these function things made what should be simple so bloomin' difficult :)
 
@Kevin I predict that too, let me check
I agree with @JonClements
Some stuff are slapped too early at us, making it hard to grasp some time
 
Yeah, it's like, what's the worst that could happen if they push that lesson ahead a couple semesters?
 
Funny thing is I got lecture every day monday-thursday
It's so fast :O
 
Anyway, one way to do it that makes sense...
import re

for word in ['hello', 'helllo', 'hellllo', 'helllllo', 'hellllllo']:
    print word, len(re.findall(r'(.)\1', word))

hello 1
helllo 1
hellllo 2
helllllo 2
hellllllo 3
 
If I use the for i get 0 lol :P
Let me test it and see if it passes the check
 

« first day (1300 days earlier)      last day (3665 days later) »