Trying to integrate numpy ndarrays in the code I have something that looks like this dpaste.com/3SPTGVG I was wondering whether there is a better way to do it with numpy.
We had Wimpy for a while here in Oz, in the mid 60s to mid 70s. They never had a good reputation, and once McDonalds arrived they didn't survive much longer.
@roganjosh That code is very confused. There is a common thing where people mess up the callback function, and we have a canonical for that. But that's not what's going on there. In fact, I'm not sure what's going on. I'll have to look a bit closer & think about it.
@Aran-Fey the callbacks part of Tkinter I never understood, I played with it when I was just learning Python and never went back when I understood a bit more. But I do remember that binding functions to command directly had bad implications
Nothing that I work on now could go through something like tkinter (unless I'm really badly informed) so I don't have interest in it beyond something I see cropping up regularly on SO
All my code changes take ~1 min to run before I can see whether they work as intended (on my current project). I don't ignore any tags, I try to use that time to keep the Python tag clean as a whole
@roganjosh There are two common gotchas with Tkinter widget callbacks. The simple one is when someone calls the function command=somefunc() instead of doing command=somefunc.
The more subtle one is when they want to pass an arg to the function, so they have
for i in range(5):
tk.Button(root, text='Button {}'.format(i), command=lambda: somefunc(i)).pack()
But that won't work, due to late binding. Instead they need
for i in range(5):
tk.Button(root, text='Button {}'.format(i), command=lambda i=i: somefunc(i)).pack()
@wim I don't mind Tkinter questions. But it's not easy to get a good answer in first if Bryan Oakley is online. :) I just wish that more OPs would post runnable code. Just adding the necessary boilerplate to get their code snippet runnable wastes half the answering time. And don't get me started on the proportion of questions that use star imports... but I guess I can blame the Tkinter docs for encouraging that.
I actually might block tkinter as a tag. I've lived the last few years assuming that I just couldn't piece things together with no programming knowledge. Now I feel the library functioning detracts from my understanding overall
Good job they implemented those gigantic buttons so I know how to block stuff
Now I have this knowledge, I want them to give a "trigger warning" modal when you inadvertently click a question that imports tkinter
cv-plsstackoverflow.com/questions/52428709/… unclear. I gave a preliminary answer but I think it's going to be iterative in solving their issue. I'll delete my answer once closed.
Doesn't sound like you're being very welcoming. Perhaps you need a sticker or something for opening those questions
Garbage is getting through with niche tags. I'm bored of it but I keep trying to clear it up. A 1 rep user using nltk tag (random example) in their question stops a lot of people opening it. If you actually look at it, it's often garbage but they're not getting critical mass to be closed
I'm not sure what you mean by "behaviour for a lambda"
the problem is that I suspect "closure" is again a thing that means something in other languages but doesn't necessarily exist in python in the same way
My vague notion is that in other languages a closure is ~ when a variable in an outer scope is bound by, say, an anonymous function. I.e. sort of the opposite of the behaviour of lambda: fun(i), whereas lambda i=i: fun(i) will bind on definition which is more along the lines of what I think a closure is
It's not really a closure. It's using a default arg. Doing it without a default arg gives you a closure: tk.Button(root, text='Button {}'.format(i), command=lambda: somefunc(i)). When the button is pressed somefunc gets called with whatever i in the enclosing context happens to be at the time. Whereas tk.Button(root, text='Button {}'.format(i), command=lambda i=i: somefunc(i)) calls it with the value that i had when the lambda was defined, as per usual with default args.
@CarloFedericoVescovo How come you posted 4 answers to this question? stackoverflow.com/questions/48836129/… It would be nice if you consolidated the 3 undeleted answers into a single answer and deleted the others.
@AndrasDeak Reminds me of that crazy code that Andrew Barnert posted that changes the value of a Python int.
Not sure about that particular case, but I generally wish people would post multiple answers more often. Two different solutions should be posted as 2 different answers so that they can be voted on separately
@AndrasDeak "I see async and the only thing I can think of is someone saying "I think" with a horrible horrible accent" I wonder how Peter Lorre would have pronounced it...
@PM2Ring I don't understand the flash-delete but the fact that my first instinct is "I need to edit this mess" on seeing a post is a decent enough reason that it probably shouldn't be on SO
@Aran-Fey Perhaps. But plenty of the old guard would strongly disagree. In my very early days on SO I tried to do that, and 3 or 4 high-rep users harassed me into merging my answers. At least, I think they were high-rep. When you've got less than 200 points, 1000 seems like high-rep. :)
I'm not at Andras' speed of typing, but I suspect that, at the rate I refresh the question feed, 90% of the question's lifetime exists in being typed out. It's odd that so many die in that short window of being edited.
I'm reasonably fast for someone who never learned to touch type. But I do lots of dyslexic transpositions, like 'expalin'. I almost never get that right. :)
I started on my grandma's clunky old mechanical typewriter. Touch typing on those things wasn't exactly easy. I did manage to get some practice in on some more modern mechanical typewriters though. And a few years later when I started coding I was using an IBM 029 card punch, which was fun.
"Academic" I always see it in my head as "achademic"
Some of the weirdness you can definitely overrule in your head, but some will stick and I guess it'll last a lifetime now. I'm 30 and still second-guess myself on spelling my mother's name