« first day (2767 days earlier)      last day (2197 days later) » 

user8177336
12:04 AM
sprouts. cabbage sir. potato? lemon for correcting me. Laurel
 
user8177336
Jon Clemens haha more like emmanuel macron
 
user8177336
avacado
 
cucumbers
 
user8177336
peas
 
user8177336
12:08 AM
any fans of jim gilmore
 
coffee?
 
please don't overdo it
 
what should't i overdo @cᴏʟᴅsᴘᴇᴇᴅ
 
user8177336
I'm mushroom. @cᴏʟᴅsᴘᴇᴇᴅ told us to look at sopython.com/salad
 
I didn't tell you to murder it
 
user8177336
12:21 AM
well im a green bean to the salad language so i didnt really know. sprouts about that
 
user8177336
chriszzzzz cbg
 
What's up?
 
user8177336
nothing much dude. what about you
 
nothing much either
chrisz
 
user8177336
@chrisz u play b ball for fun?
 
12:34 AM
Haha, talking about my profile image?
 
@chrisz I'm surprised our HNQ is still alive and well, despite the lack of activity...
 
user8177336
yeah lol. if im not mistaken u are the one in the tux right @chrisz
 
@chrisz don't answer that, it ruins the suspense
 
user8177336
nooooo
 
user8177336
dont do that. i will literally cry from the suspense.
 
12:36 AM
no but seriously, you shouldn't fish for personal info here ;)
 
user8177336
lol was just wondering cuz thats a cool pic
 
Nah I'm the one in the raptors jersey. That team is called the Sham Fam. My college had like 4 leagues of IM basketball, me and some friends would play in the lowest league, and wear costumes and stuff to every game. I played half the season in a gorilla suit.
That pic is us after winning the championship
 
Oh, Toronto is the only Canadian NBA team, also called the Raptors
coincidentally
 
That is an NBA jersey. Vince Carter.
 
user8177336
nice dude. i used to play basketball back in college as well. played for wisconsin for a year then dropped.
 
12:39 AM
really? Is that the Toronto Raptors?
 
You know it
 
I played baseball and football
 
user8177336
dang mustve been rough
 
I don't really play basketball, but I played for fun. I actually play soccer, tennis and baseball.
And I've been getting into a lot of cricket recently
 
that is cool. I just work out doing 40lb bicep curls and around 100 pushups and around 30 pullups
 
user8177336
12:41 AM
oh my god. what the.. i love cricket. how come u like such a rare game that is never played in the us. @chrisz
 
Move to texas, game is huge in Houston
 
user8177336
must be a lot of indians there too. :P i live in the valley so i see a lot of people playing cricket here all the time. i join them a lot of times as well
 
hahahaha!
 
I don't think I could ever live in Cali
 
user8177336
oh come on. u live in houston. must be the most boring place on the face of the planet
 
12:45 AM
sure, if you count almost being wiped off the map by a hurricane as "boring"
 
i never lived in cali
 
I moved in during Harvey. It was not fun.
 
I live in the northern Canadian forest
Dammit. 2017 hurricane season was evil
 
user8177336
what do u mean by moved in? like moved to like austin or something
 
No, like I moved down to Texas during Hurricane harvey
 
user8177336
12:47 AM
oh. dang must've sucked. i thought u meant u moved out to avoid it lol
 
are you guys busy
 
user8177336
yes that is why im on stack overflow chat. lol
 
which project are u doing
Hey Vanessa!
 
user8177336
1:02 AM
whos vanessa lol
 
user8177336
what do u mean what project
 
@BOI Which computer science projects are you currently doing?
(Vanessa recently joined chat, I am just greeting)
 
user8177336
oh many projects right now
 
me, mostly a java candy crush project (which is private) and a python project
Do you know wikia? That wiki hosting site
 
user8177336
nice. yes ik about wikia
 
1:10 AM
do you read any wikis?
do you contribute in any wikis?
 
user8177336
sometimes mate
 
what is your username on wiki? Which wikis do you read right now
 
user8177336
1:26 AM
my name is BOi
 
user8177336
i havent read in long time mate
 
Cool.
I am also Mulliganaceous. But all caps and decorated with hyphens
 
user8177336
im sorry mate did u just laugh at my username huh?
 
user8177336
lol
 
user8177336
rude very rude indeed
 
1:30 AM
Nope.
 
user8177336
what does mulliganaceous mean?
 
Sorry about that. I am just meaning :)
Containing mulligans
 
user8177336
i was just kidding btw when i asked if u were laughing. u didnt have to change haha to cool. lol
 
user8177336
sorry about my bad sense of humour
 
I thought I would be kicked.
when did you first join stackoverflow?
how was your first days in SO been
 
user8177336
1:35 AM
i joined like idk a year ago. so im not that new to SO. but i started using SO chat like idk 4 months ago i think.
 
user8177336
my first days on SO chat were horrible
 
user8177336
people were accusing me of being the second account of another troll that had been banned previously. His name was apparently @TheOneWhoMade.
 
user8177336
yeah...sucked
 
I have became active within the last month. Already gained 643 reputation. (technically 543 due to the "trivial" assoc bonus)
But technically I signed up on July 1 2017 as a read only user.
What bout ur first days on SO asking q and a?
 
2:33 AM
Cabbage
 
hey pm
 
@AlphaRomeo img = PhotoImage(file="blue.png") That won't work: Tkinter can only recognize GIF or the NetPBM formats. If you want to read other image file formats you need to use ImageTk.PhotoImage from PIL. I'm surprised that your program ran: you should get an error message: _tkinter.TclError: couldn't recognize data in image file. BTW, you should stop using that evil "star" import; see here for details.
Hi, Mulliganaceous.
That's what I like to see: a 1-rep newbie thanking me for dupe-hammering their question. stackoverflow.com/questions/50265202/…
 
Here is another question I got duped
I actually accepted the dupe
 
2:58 AM
@BOi accusation? You mean observation
@Mulliganaceous Also, please don't one box content that isn't noteworthy. Same thing goes for stars, I've already advised you about that yesterday
 
What does "one box content that isn't noteworthy" mean?
 
when you post a link on its own, a preview is rendered, as you see above
 
Okay. How can I disable that?
 
link + <some text here>
 
@Mulliganaceous You just need to add some other text, apart from the link. But don't worry too much about it, it's not a big deal when you link SO posts, since they don't consume too much space. But I guess I should move that one.
 
3:01 AM
Okay thanks.
oh god I couldn't delete it anymore. Try this: stackoverflow.com/questions/49807226/…
 
I'l brb for around an hour or so
 
3:10 AM
@cᴏʟᴅsᴘᴇᴇᴅ I took pity on the OP and started to write a correct answer after someone else wrote one that doesn't address the OP's requirements. But then go shut out by your CV ;-(
/shrug oh well...
 
if you didn't want it closed you shouldn't have asked for a cv pls ;/
 
when I asked I wanted it...
 
Best thing to do would be to leave a comment under the incorrect answer and/or dv
 
but then I changed my mind and wrote an answer
yah, I've posted several comments already. Hopefully the OP can piece it together.
 
Do we have a dupe for None in doctest?
 
3:19 AM
@chrisz I don't think there's one in our collection, the only mention of doctests I found was here. But I don't use doctests, and I haven't played with them much, so I don't tend to keep track of doctest-related stuff.
 
@cᴏʟᴅsᴘᴇᴇᴅ Okay, after many comments, the dupe seems appropriate. What the OP wanted was not what I originally thought and wrote an answer for. Probably **kwargs will suit their purposes, but I'm no longer putting any energy into it.
 
@cᴏʟᴅsᴘᴇᴇᴅ Thanks for the CV!
(belatedly)
 
yeah, best to close the tab and move on after a point, it isn't worth it
 
I have a permanent SO tab open. I just click back to the home page when I'm ready to move on.
 
3:34 AM
@timgeb I vaguely remember searching for a way to convert all Unicode text to escapes a year or so ago; I can't remember exactly why. :) If there's a way, Martijn may know (he has the Unicode gold tag badge), but I'm pretty sure I asked him already. On a related note, if you want "clean" Unicode escapes rather than Python-flavoured ones, try json.dumps. To convert all chars to \u or \U escapes, the best I can come up with is something like:
''.join([f'\\u{c:04x}' if c < 0x10000 else f'\\U{c:08x}' for c in map(ord, s)])
 
cbg. Why do SO users keep reanswering duplicates? stackoverflow.com/questions/50322592/… -> stackoverflow.com/questions/3941517/…
 
Looks like abarnert felt it was worth reopening to answer
I'll defer to his sense of judgement, if there's anyone I would prefer answer blatant dupes, it's him
 
@smci That linked question doesn't answer what the new OP is asking. « note that I want to argument interface to be explict. That is explict write argument names as ff(a,b,c) when making function definition»
 
So I jumped the gun on which duplicate and identified the wrong duplicate. but still it must be a duplicate of some existing question. Which one?
 
@smci I don't expect that it is a duplicate. What the OP wants to do is not usual Python practice. He's trying to use an idiom from another language in Python.
 
Why don't need that silly getArgValueList function, because we can do *args.
@cᴏʟᴅsᴘᴇᴇᴅ " Please debug your code a little more thoroughly before asking a question. " You don't need to say that. It comes across as condescending and rude.
 
Trust me I revised that comment 3 times before posting it
I'm really bad at this
(well, edited now) but I really think it should be said to OP, no matter how politely
 
At least you managed to fix it in time. :)
 
Yes, map(myfunc, args) seems fine to me. Seems perfectly Pythonic too. As to existing duplicates, there are 1,827 hits on stackoverflow.com/search?q=%5Bpython%5D+map+args
 
@cᴏʟᴅsᴘᴇᴇᴅ Agreed. And it can be hard to say stuff like that diplomatically.
@smci If you can find a good dupe, I'll be happy to re-hammer that question. OTOH, I'm glad abarnert answered it. Although it's not what the OP wanted, it may help some future reader.
 
3:52 AM
There are 1,827 badly-worded hits and I don't have the energy tonight... we are drowning in badly-worded/tagged duplicates and triplicates. Does anyone else see this as being a major problem?
 
@timgeb Speaking of Unicode stuff, you may find this amusing: how to decode UTF-8 by hand. ;)
 
Like this one "Using python's map() with multiple args?
" https://stackoverflow.com/questions/2031216/using-pythons-map-with-multiple-args really turns out to be "How to iterate more efficiently over 80x60 array of pixels?"
 
@smci Certainly! Do we have the manpower to fix it all? No. But we do try to fix up Bad Stuff when we notice it. Eg, the other day Aran-Fey found that a popular old dupe-target had been misapplied to almost 20 questions, due to those questions not having been read correctly by the dupe-voters. Unfortunately, we couldn't find a good target that does apply, and he's thinking of writing a self-answered question to use as the dupe
@smci Classic. Of course, we can't expect OPs to come up with perfect titles. But I do expect people who edit questions to also edit the title when appropriate. It's amazing how often the title gets ignored by editors, considering how important the title is when you're doing searches.
 
And remember that most of the stack overflow traffic are through google and search engines
90% of them
 
@PM2Ring How do you mean "It's amazing how often the title gets ignored by editors?" Why is that?
 
4:22 AM
@smci I often see questions that have been edited but with a bad title that can be easily improved. I don't know why those editors ignore the title. OTOH, I confess that sometimes when I answer a question with a poor title I forget to fix it myself. But I'm not a low-rep user desperate to get 2 points by doing a quick edit. ;)
 
4:40 AM
@PM2Ring I agree this seems to be a huge problem, people don't find duplicates because of crap titles. What should SO be doing about it? If they need to incentivize users to improve titles, then they need to incentivize users. Or punish bad, lazy or misleading titles.
 
@smci You can punish sloppy low-rep editors by rejecting and improving their edit. That way they don't get the 2 points. And you can leave a comment telling them why you rejected it. IMHO, such editors should lose 2 points, but that's never going to happen.
Of course, that only works on edits that are still waiting to be approved. Maybe we should also be punishing people who approve bad edits. That has been suggested on meta, but nothing's ever come of it - it'd be too hard to implement it fairly.
 
4:56 AM
I'm always hesitant to edit titles to describe the actual problem that the question faces., but it would probably make flagging questions easier.
 
@chrisz Sometimes it can take a bit of comment dialog to get to the OP's actual problem, and in such cases you don't want to change the title prematurely. If the OP is actively editing their question, I'd propose a better title in a comment. Otherwise, just edit it yourself (leaving an appropriate edit comment, of course), and if they don't like it, they can always roll it back.
 
Yea, tends to be something that's easier to do in retrospect, after the question has already been answered.
 
Any specific suggestions on how you'd have handled "Using python's map() with multiple args?" stackoverflow.com/questions/2031216/… which I edited into "Optimize Game-of-Life iteration over 80x60 RGB pixel array". The original title, and insistence on a non-matrix formulation, and tons of pointwise calls to individual pixel elements in pygame.Surface, were never going to be efficient.
 
can anyone suggest improvements to the question title here? meta.stackoverflow.com/q/367846/4909087
 
And you can earn badges for editing questions that you answer. stackoverflow.com/help/badges/4369/refiner stackoverflow.com/help/badges/4370/illuminator
 
5:12 AM
I'd say that was a high-quality high-effort question, but very XY. Most questions with bad titles are the opposite. So how much carrot and how much stick to apply? do we penalize people who repeatedly ask duplicates without showing research effort? Currently we don't
 
@cᴏʟᴅsᴘᴇᴇᴅ Tricky, since such titles are traditionally required to incorporate a pun. ;) I'd shorten it to Freedom from the bonds that [bind] us
 
@PM2Ring I'm not talking about incentives for the <1% of users who edit the tsunami of bad titles. I'm talking about the users who post the tsunami of badly-titled questions. Also the ones who answer them knowing the question is a likely duplicate without doing any research to close.
 
@PM2Ring v nice, I'm stealing, er, borrowing that, thanks!!
 
5:28 AM
@smci As I said earlier, "we can't expect OPs to come up with perfect titles", especially if they're new. They seem to have a hard enough time writing answerable questions, or improving their questions in response to comments.
Some people who answer blatant dupes can be encouraged to do dupe searches, others will never change their ways because they want the points. Sure, you can downvote such answers, but I'm hesitant to downvote answers that are technically correct, since that can mislead readers into thinking the answer is technically poor.
 
back again!
Refiner is quite rare though.
@PM2Ring
 
Various things have been proposed on meta to encourage dupe-searching, eg by giving rep & / or badges for finding good dupe targets. That would probably require a mechanism to allow us to vote on proposed dupe targets. And that would take time (and hence money) to implement. And there's no guarantee that it'd make much of a difference. OTOH, while people can earn points for answering dupes but get no reward for doing dupe searches we will continue to get people answering dupes.
 
How about flagging for dupes. With me at around 600 reputation, I am not able to vote to close
 
@PM2Ring I made the mistake of giving certain users feedback on their posts when downvoting. Now they think every downvote they get comes from me, and they never miss a chance to return it
 
@Mulliganaceous I've got one. :) And I'm working my way towards Copy Editor & Illuminator.
 
5:37 AM
For me, whenever I downvote, I usually prefix my comment with "Downvote" to indicate that the downvote is from me, and that the poster must respond by improving their answer and replying back to me
Also, I already changed downvotes to upvotes several times for those who manage to refine their posts.
 
@cᴏʟᴅsᴘᴇᴇᴅ Avoiding revenge downvotes is tricky. I learned long ago never to DV & comment at the same time.
 
well, at least it makes it obvious that users like that are beyond help or improvement—they're so intolerant to feedback that they would just as soon flag your comments for abuse than actually respond to it
 
I usually downvote questions from beginners so they can respond to my comment and edit the post so I can answer them. And change the downvote to upvote.
 
If I see a technically poor answer I offer constructive criticism in a comment. I only downvote if they don't improve their answer, and I give them at least an hour to do so. Of course, that doesn't apply to a technically correct answer to a dupe.
 
The opposite occurs for me. I downvote them so they would have to edit.
However, for questions which are completely unclear or poorly formatted, I just simply downvote and flag.
 
5:48 AM
I want to play devil's advocate for a moment. It can be hard to find a good dupe target, even when you feel the question is likely to be a dupe. I've done a lot of dupe hunting (even before I got the Python gold tag badge), so I'm pretty good at finding appropriate dupe targets. If I can't find one after a few minutes searching I assume that the OP and other potential answerers won't be successful either.
In such cases, I think it's fair enough to write an answer than to waste more time in a frustrating search, even though you know there's probably a dupe target hiding somewhere.
 
@PM2Ring Right. Feels we're missing an incentive to close an obvious duplicate. How about if you vote-to-close as duplicate, and that eventually happens, you get a small incentive, and if you correctly identify the duplicate used, more bonus. Now should existing answers lose some(/all?) rep from upvotes if something gets closed-as-dupe?
This would swing the pendulum in favor of overly-enthusiastic closing, but I think we've reached that point.
 
@smci I'd condense that to "Optimize Game-of-Life iteration over RGB array"; I agree with your other points. And I'm not impressed with the accepted answer using assert to validate function arg values. If you're going to raise an exception for bad arg values we have ValueError.
 
@PM2Ring Please unlearn it. Offer criticism, and don't worry about occasional adverse reactions. Mind you, IIRC I find your tone sometimes too harsh. There's a wide space in between nurturing and insulting.
 
@smci All of those things have been proposed. Penalizing correct answers is not popular. We can encourage people to post their answers on the dupe target, but in most cases they'd need to change their answer a little so that it matches the old question.
 
@PM2Ring thanks, my function looks pretty similar to your suggested solution.
 
6:00 AM
@PM2Ring not sure we should drop 'pixel' from "Optimize Game-of-Life iteration over 80x60 RGB pixel array". Part of the OP's confusion was getting hung up on just because some packages offer a pixel object, that they should necessarily use it anytime they want to represent a pixel. When essentially they should have been looking for a 2D matrix formulation. (3D really if R,G,B, are the third dimension)
 
@smci I try hard to not be harsh, unless the recipient is a repeat offender. Or if the question is a blatant no-effort homework dump. Of course, I may not always be as diplomatic as I'd like to be, especially if it's getting late and I've seen a lot of bad questions that day...
 
@PM2Ring How many "bad" questions? How do you usually deal with them?
 
@PM2Ring Ok well it feels the time has come, how do we convert that discussion into action? and how to chronicle how bad the everyday problem has now become without shaming specific questions and users?
 
Just remember most of the poor questions are the first questions by the 1-rep users.
 
@smci Sure, but that can be covered in the question body. Titles should be succinct. I suspect that most people would interpret "RGB array" to mean some kind of array of pixels.
 
6:02 AM
However, I am nice enough to grant upvotes if they do not deserve a downvote
 
@PM2Ring (IME you sometimes jump the gun on answering before fully understanding the question, including with me. LMK if you want to ever PM you with if I see an example).
 
was that a pun on PM?
 
@Mulliganaceous Well, sure. And they don't have any points to lose, so downvotes don't mean a lot to them, and although getting a lot of downvotes can lead to a question ban, many low-rep newbies will simply just create a new account if they get a ban.
 
@PM2Ring Err, I humbly disagree. If you read the question, the OP was wedded to pygame.Surface, declaring a 2D array of it, accessing it with get_at/set_at method calls, not trying to reduce the formulation to a few lines of matrix algebra and letting numpy handle the rest.
 
The automatic question (and answer ban) is "Lower level than account"
It affects the IP address as well
 
6:06 AM
@smci I didn't look closely at the question, and I don't know pygame.
@Mulliganaceous Oh, ok. Still, that's not a big barrier to someone who creates their account using a disposable email address on a public computer at school, in a library, etc. And an IP ban doesn't work too well if your IP address is dynamic.
 
Do you know any offending accounts who bypass IP bans?
question and answer bans?
 
@smci I'm always happy to get constructive feedback on my answers. Either post a comment, or for more complex stuff ping me in here.
@Mulliganaceous No, but I'm not a diamond mod, so I don't know the details of how they handle that stuff. And of course if you ask mods about it there's a limit to what they'll reveal.
 
Okay. PM, how often do you encounter posts that require red flags?
(I currently found four)
 
@Mulliganaceous your good friend BOi is under suspicion
 
what did I do wrong?
 
6:16 AM
is your name @BOi?
 
Nope.
 
@Mulliganaceous Not that often. I don't go looking for people trying to work around bans. But I have alerted mods to possible sock puppets a few times.
 
Why did you mention that BOi is under suspicion? @cᴏʟᴅsᴘᴇᴇᴅ
 
because you asked if there were any offending accounts who bypass bans
 
Okay.
Coldspeed, you are a marshal!
with 1119 helpful flags. I only got 93
 
6:20 AM
Serious claims require serious evidence. BOi denies having had a previous account, and I'd rather we don't cast further aspersions in this room.
 
Okay. Let's stop talking about it now.
(It is 2:22AM in my zone, gotta go sleep soon)
@cᴏʟᴅsᴘᴇᴇᴅ It is amazing that you could pull a 80K in the span of less than a year.
 
@PM2Ring agreed.
also, please ensure Andras gets the memo, because it seems like he's the one casting the most aspersions here
 
@abarnert In reference to this: IME, people new to Python from Java seem to have a strong tendency to treat Python as a funny dialect of Java, which can lead to puzzlement and frustration when things don't behave the way they expect. Of course, it takes a while to get used to the idioms of a new language, but that process takes even longer when you keep trying to use the old language and refuse to embrace the new one. ;)
 
Python is interpreted. When I started learning Python I committed several "javaisms", which are syntax errors because I was more into java back then
Also in python you never declare variable types, and you always use self when you are working with class variables
 
@Mulliganaceous That's because in Python we don't have declarations. And we don't have variables. :)
Mar 21 '17 at 8:27, by PM 2Ring
@Drizzy In the mean time, here are a couple of articles that explain a very important difference between Python and most other languages. Other languages have "variables", Python has "names", and Facts and myths about Python names and values, which was written by SO veteran Ned Batchelder.
 
6:35 AM
Everything is an object in py
 
Also, self is just a convention. You can use any name you like, although that's likely to confuse most Python veterans.
 
Self is pythonic. Whereas java uses this
 
@Mulliganaceous That gives Python a certain OOP purity, but it comes at a price. Because we don't have primitive non-object numeric types or characters, working with such things in plain Python is a little slow. Of course, we can use stuff like Numpy when we want the speed of machine numeric types.
 
Numpy arrays are as fast as c arrays
 
Or Fortran arrays. :)
Of course, converting Numpy array numbers to Python numeric objects is relatively slow (compared to pure Numpy operations). But often that's not required.
 
6:45 AM
is there any point of a python linked list
Last year I learned linked lists and implemented in python
 
How odd. 2 questions asking about code that's supposed to be roughly equivalent to functools.partial: stackoverflow.com/questions/50323054/… and stackoverflow.com/questions/50324135/…
 
@PM2Ring Yeah, I know. But asking for a function like JavaScript arguments or perl $@ is not a sign of Java disease. In fact, it's almost refreshing to see a novice trying and failing to do something completely unpythonic that isn't about "I defined a __private variable and now I can't access it" or "I made a thousand `@staticmethods instead of just plain functions but they can't access my class attributes".
 
Hey @abarnert!
 
Occasionally, linked lists are useful. They're used in the implementation of OrderedDict, for example.
 
Thanks for your answer on my last question.
 
6:50 AM
@abarnert I'll pay that. :) And it is natural to try to replicate stuff you're familiar with when you first learn a new language.
 
Sadly, it is now on hold. I got no time today, gotta sleep now.
I might see you next time though. When are u active on chat @abarnert?
 
@Mulliganaceous Weren't you discussing this topic here in the last day or so?
 
It was now on hold. I need to revise this question
but today I will just leave it
 
I'm active on chat randomly, but mostly whenever the build system at work is down or I'm frustrated by some horrible Go code and there aren't any good Python or C questions to distract me. :)
@PM2Ring I assume someone just taught their class about partial, and asked them to work it through and figure out how it works? (If so, that sounds like a pretty good class.)
 
Thank you. (Gotta say goodbye now) Next time. X.D.
 
6:54 AM
I have a whole github repo full of my attempts to translate Python (and Haskell) idioms to Swift. I did it mainly to teach myself how the Swift iteration model is different from the Python one… but then I found myself using it in real code. Which of course all broke with Swift 2.0.
 
@abarnert That was my thought, and it does sound like a good class, even though I'm not partial to partial: it's disappointingly slow. I guess there's no getting around that extra level of function call.
 
@Mulliganaceous please leave lurking users alone. We have a lot of silent drive-by users and addressing tgem all out of the blue is annoying
 
I like partial a lot more than wrapping the function in a trivial lambda or def. I tell myself that it's for the better introspection and debugging, but it's probably just because it feels more like ML/Haskell/F# and less like Lisp, and I'm doing the same importing-another-language's-idioms thing we were just talking about. :)
 
Sure, if you're going to do currying in Python you might as well take advantage of partial, unless you need to do stuff it can't handle, like re-ordering of positional parameters.
 
Anyway, I think there's a lot more of a problem with instructors new to Python (or who just don't like Python) teaching their novice programmers Javaisms. Most of those __private questions, when you ask why they used it in the first place when they don't want what it does, they say "The teacher told us to make all our variables private and write getters and setters", and sadly I can't set their teacher on fire.
 
7:01 AM
Hey, guys. I'm new here.
 
@abarnert Here is a classic example. As you can see, the OP was not impressed with my comments. ;)
 
cbg
 
Hi @Sean, welcome to the Python room! Make sure you check out our room rules.
 
I already did. And cute fluffy animals are amazing! (unicorn)
 
Excellent
 
7:04 AM
I just realized unicorn is not in the Salad language.
 
That's because unicorn is not a vegetable or a fruit. :)
 
Any lexicon in Salad that pertains to something.AMAZING?
 
@PM2Ring You were being too nice to the OP; better to just drop it and move on once they start playing the "I'm too advanced for you idiots, so I demand that you answer the question I don't even know how t phrase" thing.
 
@timgeb No worries. BTW, f-strings are really fast, so if your solution doesn't use them, it probably should. :) Unless of course your code needs to run on versions before 3.6
 
Also, "slightly different OOP philosphies" is being too nice to Java. Python's OOP philosophy is "Smalltalk isn't quit flexible, dynamic, and friendly enough", while Java's is "C++ is too flexible, dynamic, and friendly".
 
7:14 AM
Gotta ask though. In Python, if you were to limit access to an instance variable to getting, i.e. you can only get the value of said variable but not change it, how would you do so since instance variables are public by default in a Pythonic way?
 
class Foo:
    def __init__(self):
        self._private_var = 5

    @property
    def private_var(self):
        return self._private_var
 
@abarnert Good idea. But since that notorious blog post I've been making an extra effort to be nice to the newbies. But that reminds me... When I was still fairly new to SO (but not to Python) I said in an answer to a question asking about X in some Python text book (I can't remember what X was) that I wouldn't trust a textbook where the author recommended doing X.
Within 24 hours the book's author was responding to the question, and he wasn't impressed with my comment. So in the interest of diplomacy I reworded my answer to be less insulting, but I didn't retract my opinion that doing X is bad.
@SeanFrancisN.Ballais Note that the user can still set self._private_var directly. But by using an underscored name you've warned them that they do so at their peril.
 
@PM2Ring
Yam
@PM2Ring Okay, I could see that you can still set self._private_var. I just tried in in the Python REPL. What's the point of using the @property decorator on a method?
@Aran-Fey thanks!
 
I do make an effort to be nice… but when they make it impossible, the best way to do that (if not always the easiest) is to just shut up and move on. People like that will take any attempt to be constructive as, at best, an invitation to start a pointless argument, and more often as a dire personal insult.
 
7:24 AM
@SeanFrancisN.Ballais That's how you make a getter. It lets you access the attribute as Foo().private_var
 
@SeanFrancisN.Ballais Well, you could hard-code the value into the getter:
class Foo:
    @property
    def private_var(self):
        return 5

f = Foo()
print(f.private_var)
f.private_var = 42
#output
5
Traceback (most recent call last):
  File "./qtest.py", line 48, in <module>
    f.private_var = 42
AttributeError: can't set attribute
 
@SeanFrancisN.Ballais Python "private" isn't about trying to make it impossible for evil code to access the attribute, it's about trying to make it easy for good code to use it correctly.
 
@PM2Ring you're right, it doesn't matter that the user is allegedly a reincarnated user. What matters is that they display the exact same unique patterns for which the previous user had been warned
 
@AndrasDeak Very true. And we can certainly criticize / penalize them when they do that.
 
Private doesn't actually work in other languages where it's supposed to be "protection". In C++, you can just use pointer arithmetic and reinterpret_cast; in Go or C# you can use the reflection API; etc.
 
7:27 AM
@Aran-Fey @PM2Ring Oh, I see. So, if you don't use the @property decorator, then you must call like the function that it is?
@abarnert So Python is being optimistic, in a sense, then. As with the other languages, private, for protection, is just one big wall that you can circumvent by different means?
 
Guido always puts it as the "consenting adults" philosophy.
 
Python generally tries to make it as easy as possible to do the One Obvious Way To Do It, instead of trying to make it as hard as possible to do the Wrong Way.
 
Isn't that phrasing considered toxic nowadays? :D
 
Some people dislike the sexual implications, but they can go get yammed, IMHO. ;)
 
7:31 AM
I could already hear the PC police sirens.
 
I doubt anyone would be offended for PC reasons. Making people think more about issues like consent is half the point of PC.
I suppose fundamentalist Christians and Muslims might be offended by the notion that you might access the attributes of a class that you aren't married to.
 
@abarnert In a Python context, how would you know that an object is married to a class?
 
The way he says "mentors for youth programming camps" makes me think he's talking about programming the youth to join his cult, not teaching them to program.
 
If he's mentoring anyone from the youth, he has the option to use "We are all responsible users" for those demographic, and just use "We are all consenting adults here" for the adult demographic.
 
7:36 AM
That sounds sensible.
 
@SeanFrancisN.Ballais Remember that Python is Dutch, not American. So you don't need an official marriage declaration; as long as asking the class to __spousecheck__ the instance returns something truthy, Python accepts that the instance is married to the class. And is a duck.
3
 
There's probably a dupe for this list partitioning / exact cover question, but it may not be easy to find. stackoverflow.com/questions/50324940/…
 
brief cbg
 
@PM2Ring doesn't this operation have a name, the set of unique subsets of length n?
 
@abarnert So, it's just duck typing? In what hypothetical case would you call __spousecheck__?
 
7:48 AM
@Arne Well, it's an Exact Cover problem, since each set of subsets has to exactly cover the original set.
 
@abarnert, okay I think I got it. So, if you call __spousecheck__ on an instance of class Foo and it returns True or something truthy as you said, then we can say thay that instance is married to Foo?
 
If the instance is trying to pass itself off as a spouse of Foo so they can swim together in a duck pond, you don't bother checking. But if they're trying to do it in a swan pond, then it's better to ask for a __spousecheck__ to be safe. Just in case one of the swans is Zeus in disguise.
It's always fun when someone accuses me of having no theoretical computer science background, then goes and checks the facts, then deletes their answer and all of their comments. I'll have you know that computer science was my second-to-last undergraduate major before dropping out, so I have as much background there as in anything but linguistics (which is what I dropped out of grad school in).
 
8:04 AM
Facts are the worst
 
cbg
 
@abarnert I'm sorry. I still don't get it. There must be some gaps in my knowledge of Python. Still trying to understand it. So this instance could be an instance of Foo? Or can the instance be an instance of another class?
 
@SeanFrancisN.Ballais I'm not sure at this point if you're carrying on the joke, or sincerely not getting the reference to __instancechck__?
 
@abarnert I sincerely did not get the reference to __instancecheck__.
 
8:15 AM
OK: __instancecheck__ allows a class to declare other things to be "virtual instances". They aren't actually instances of the class (as in cls is not obj.__class__, or in obj.__class__.__mro__), but isinstance(obj, cls) will still succeed.
It's mainly used so that you can write "structural-typing" ABCs, so isinstance(obj, collections.abc.Iterable) is true if obj has an __iter__ method.
So the joke, such as it is, is that even when you want to be more rigid than duck typing in Python, it's still a lot less rigid than what you can do in C++, Java, etc. (although Go's interfaces are more similar).
 
@Arne I know you were trying to be helpful, but when someone asks fora tag edit, please let someone with high rep do it so we don't have to wait for your edit to be approved. FWIW, those of us with 10k+ can do inline tag edits almost instantly, see the bottom of this page for details.
 
Ah, thanks for the info
 
No worries. I could've rejected your edit, but I didn't want to rob you of the 2 points.
 
Also - some people will out of habit reject tag-only edits...
 
8:25 AM
Q: What's worse than parsing HTML with regex? A: Parsing HTML with regex using grep. :) But people still do it, despite the warnings. I just got another upvote on this.
 
Do 10K+ tag-only edits still bump the question, or did they fix that?
 
Hi guys. Any ideas about this error? "can't pickle PyCapsule objects"
 
@abarnert Still trying to get it since I'm also connecting the dots but I'll look into that especially the other topics you mentioned but I am still getting the grasps of. Thanks!
 
@PCHC Are you trying to save them to disk by explicitly calling pickle.dump, pass them to a multiprocessing child process or pool, use some third-party distributed computing framework, or…?
Also, what library are you using? PyCapsule is usually about using the objects or functions from one C extension library in a different C extension library without wrapping them up in the heavier-duty way needed to make them usable from Python code.
 
@abarnert AFAIK, they still bump the question, so mass tagging is still discouraged.
 
8:34 AM
Also: builtin pickle, or dill or cloudpickle?
 
@abarnert, so "virtual instances" are just instances that happen to quack like a duck and walk like a duck, but not actually an instance of Duck?
 
They're a bit more than that—they quack like a duck and walk like a duck and can even be checked for isinstance(obj, Duck) even though their type isn't actually descended from Duck.
See PEP 3119 for the idea.
 
Okay, thanks!
And isinstance(obj, Duck) returns True if obj has methods that are in Duck?
 
No, it returns True if type(Duck).__instancecheck__(obj) returns True
class MetaDuck(type):
    def __instancecheck__(self, obj):
        return obj < 5

class Duck(metaclass=MetaDuck):
    pass

print(isinstance(3, Duck))  # True
print(isinstance(7, Duck))  # False
 
By default, __instancecheck__ just checks that Duck is type(obj) or Duck in type(obj).__mro__. But (meta)classes can override that. ABCMeta overrides it so it also returns true if you write Duck.register(type(obj)) (that's how list counts as a collections.abc.Sequence), or if Duck.__subclasshook__(type(obj)) returns true.
And some ABCs use that to return true if obj has all the appropriate methods. For example:
class Iterable(metaclass=ABCMeta):

    __slots__ = ()

    @abstractmethod
    def __iter__(self):
        while False:
            yield None

    @classmethod
    def __subclasshook__(cls, C):
        if cls is Iterable:
            return _check_methods(C, "__iter__")
        return NotImplemented
Ha, I forgot about _check_methods, my big contribution (along with Reversible) to CPython that got replaced with a slightly different implementation (to play better with typing) one version later.
The original version might be a bit more obvious:
    @classmethod
    def __subclasshook__(cls, C):
        if cls is Iterable:
            if any("__iter__" in B.__dict__ for B in C.__mro__):
                return True
        return NotImplemented
 
8:55 AM
I'm not sure what to think of that __iter__ implementation. I found a way to make it worse:
def __iter__(self):
    return
    yield
But the good solution is probably return iter([])
 
I think the idea is to force the method to be a generator function.
 
There's a difference between functions that return a generator and functions that use yield?
 
Oh wow. Well. I am confused at this point since I don't have much grasp on the ABCs and the other magic methods. Will just read the PEP doc. Thanks for the guidance!
 
@Aran-Fey, what is the difference?
 

« first day (2767 days earlier)      last day (2197 days later) »