« first day (2729 days earlier)      last day (2219 days later) » 

1:00 PM
Ok so it sounds like the categorization you have come up with is: Tkinter is a GUI library. tkinter produces ugly looking interfaces. Therefore, all GUIs are ugly, and if something is not ugly, it must not be a GUI.
But this is a misconception. There are both ugly and not-ugly GUIs.
 
Well, it's just that the experiences I have had with GUIs is that their design is quite awful
But to be honest I have only had experience with tkinter so...
It's not the smoothest looking in my opinion
And on windows the quality suck on larger monitors (a tkinter issue)
 
I suspect that may be confirmation bias. When an interface is unintuitive and obstructs your goal, you think "darn this lousy GUI!". But when the interface is intuitive, you don't even notice that there is an interface, since exceptional UIs make you feel like you're melding directly with the computer, so easy is your will converted into action.
But a GUI is a GUI even if it succeeds in making you forget it exists
 
Yeah you are right
 
"I have only had experience with tkinter so..." seems like a misrepresentation of your experience with GUIs. If your OS has a window manager, then you have used a non-Tkinter GUI.
Perhaps you meant "I have only had experience creating GUIs with tkinter", which I can't dispute quite so easily
 
pro-tip: GUI is an abbreviation of Graphical User Interface. If you see a user interface that contains things other than characters in your terminal, it's a GUI
hmm, then again some might argue that norton commander had a GUI
 
1:09 PM
As I understood it GUI is a subset of UI, and UI is thus capable of more.
 
That's not how set theory works
 
In the same sense that humans are a subset of animals, and animals are capable of more.
 
well, in a way it would, but you were looking for a different subset of UIs that are also GUIs while not being GUIs
 
Cheetahs can run way faster than us, but you wouldn't hire them to construct a freeway
 
anyway, I don't want to waste too much breath here :P
 
1:12 PM
So perhaps it's correct to say that UIs as a group are capable of accomplishing a wider variety of things than just GUIs alone. But that doesn't imply that any one UI is superior to any one GUI in all categories
 
I don't know, it's hard to beat nethack's intuitive interface
 
Amazon Echo has a solely audio-based UI, and you won't find an easier way to play a song than "Alexa, play Never Gonna Give You Up". But I'd hate to try to do my taxes with a UI like that.
 
Thanks that cleared out some stuff. Not just some stuff, but a lot of stuff.
 
@Kevin amazon probably knows more than enough about you to do your taxes, perhaps it's worth a shot
 
I wager 1 quatloo that there's a humorous easter egg response
 
1:15 PM
if I were amazon the response would suggest asking google home to do that
but there's probably a distinct lack of humour when it comes to industrial competition (unless we're talking about car adverts)
 
jjj
cbg peoples
 
To circle back a bit, I do think the general concept Sebastian is gesturing at is a real thing, albeit not by the name he was going with. Nobody would dispute that there's a material gulf between the interfaces of, say, Windows 95 and MacOS. You can look at a button with rounded corners and a glossy shine and say "this is smoother and nicer than a bezeled gray rectangle"
 
But those differences are on the level of buzzwords, not technical differences
 
jjj
if I may interrupt with (maybe) a silly question but why is json in the stdlib and yaml is not? Are there some obvious reasons?
 
I think it's a qualitative distinction, not a quantitative one. In other words, if you start with an ugly interface design and iteratively improve it, there's no point where you can say "I have just taken my first step into the realm of Smooth and Nice interfaces". You just look around you one day and find yourself surprised that you've been in the Smooth and Nice dimension for who knows how long. It's the paradox of the heap for the modern era.
 
1:21 PM
Can't interrupt off-topic musing with python
 
jjj
:)
 
Just get the hand cart and wheel me into the far corner of the room, where I will continue to share my thoughts with the potted plant
Try hanging a heavy coat over my face, that should muffle it somewhat
Bonus: I might think it's night time, and go to sleep.
 
Don't you go to sleep when covered?
Ah OK
 
jjj
@Kevin dont wanna sound too nice but I think the room likes when you share your thoughts
(Starboard let me come up with that stellar thought)
 
That, too, is confirmation bias. The room likes it when I share my insights, but not my pablum.
But I don't know which is which until I press "send"
 
1:27 PM
I'm on mobile but this might indicate some relevant discussion mail.python.org/pipermail/python-ideas/2013-June/021027.html
 
@jjj Interesting question. Perhaps more information can be found in the release notes of whatever Python version first integrated the json module.
 
jjj
Thanks you two, I'll look into that
 
Here it is. Doesn't say much.
 
Whad'ya know, @abarnert is everywhere ^
 
@AndrasDeak I haven't seen abarnert since I was prospectin' out on Subterrel
 
1:30 PM
@JGrindal had to google that one
 
The original root message, mail.python.org/pipermail/python-ideas/2013-May/021003.html, seems to mirror jjj's exact question
> Is there a reason for not including a YAML lib that i didn’t cover?
Is there a reason JSON is used other than YAML not being in the stdlib?
mail.python.org/pipermail/python-ideas/2013-May/021007.html gives the usual "because nobody proposed including it", which is a little curious because I'm pretty sure there's no PEP for json either
 
@Kevin might be because yaml is hard
 
Summary of top level responses during the month of May:
If you want YAML, give us the code.
YAML isn't as popular as JSON.
JSON looks pretty Python-y, and is therefore better.
YAML has the potential for arbitrary code execution(?).
YAML is real complicated to implement.
 
wasn't it in this chat where specification length of encoding standards were compared and yaml's ended up being a good chunk longer than xml?
 
1:45 PM
Sounds like something we might do.
 
I think it was. On that day I learned about TOML as an alternative
 
jjj
@Kevin maybe there is no pep for json but it is somehow implicitly "proposed" in peps for metadata standards here and here
 
In a retroactive sense. The json module was introduced during the 2.6 release on October 1 2008, and those PEPs are from 2017 and 2012
 
jjj
Also this quote from Nick Coghlan (linked to by Andras) is quite illuminating for me:
While having a YAML parser in the standard library is a defensible
idea, it still wouldn't make any difference to the packaging metadata
standards. Those are going to be strictly JSON, as it is a simpler
format and there is no technical reason to allow YAML for files that
should *never* be edited by hand.
 
So that lets us fill in a blank on our History of json map: "2012 - json definitely exists from this point forward". But the area we're interested in, the zone between conception and introduction, is a big ol' question mark
 
1:52 PM
there's also this note in the json docs:
> Note: JSON is a subset of YAML 1.2. The JSON produced by this module’s default settings (in particular, the default separators value) is also a subset of YAML 1.0 and 1.1. This module can thus also be used as a YAML serializer.
 
jjj
^ how do you cite in chat? Couldnt find that anywhere
 
Let's talk about set theory again
@jjj stick a greater-than sign at the front of the message.
 
jjj
> thanks
 
One of the few markup symbols that actually works on multi-line messages.
(The only one, possibly?)
 
and link syntax might work too? unsure
 
1:56 PM
How do I test if I configured setup.py correctly for a project?
 
@jjj interesting, I would've sworn it's either in the help or the faq, but I can't find in either
 
jjj
well, I decided its quicker to ask here after a while, so maybe it is somewhere.
 
I'm sure there are meta posts about it, but this basic functionality should be in the "how do I format my messages?" section of the faq
 
jjj
It's not there
 
7 mins ago, by Andras Deak
@jjj interesting, I would've sworn it's either in the help or the faq, but I can't find in either
 
2:04 PM
45
Q: Which links and sites are handled specially in chat?

Juha SyrjäläThere is a special linking to some sites in chat, also known as "onebox". What is the full list of supported and integrated sites? Return to FAQ index

 
jjj was asking about quote syntax
 
I'm seriously considering making a feature request on meta to get ">" added to the FAQ
 
yup ^
it should be there
 
jjj
me too :D
 
strikethrough got added in '12 so I think I'll just copy that question's format
0
Q: Add "> text" quote markup to chat FAQ

KevinIt's possible to quote a block of text in chat by preceding it with a greater-than sign: > I've got a lovely bunch of coconuts This produces a nice vertical dotted line in the message. However, that's not specified in the chat FAQ. I think it should be added.

 
2:10 PM
that's meta.SE, not meta.SO
did you check the chat.SE faq?
 
Is there a difference?
 
@Kevin yes, two different systems
my gut feeling is that SO feature requests should go on MSO, but I'm unsure
 
Strange, chat.stackexchange.com/faq#formatting and chat.stackexchange.com/faq render differently for me even though they're the same url not counting the fragment
 
same here, must be usual SO magic
 
Can some one clear my doubt in django and python
?
 
2:14 PM
@user5444075 please don't ask before asking, just ask and we'll see. And please don't use unnecessary newlines in chat :)
 
Do you?͏͏͏͏͏͏͏͏͏͏ — Bathsheba 4 mins ago
Hmm is this like a sly way of saying "ok, you told us you wanted a thing, what are we supposed to do about it?"
Which is a sly way of saying "ask on SO, not SE"
 
I think they refer to the coconuts
 
It's about coconuts, I guess
 
Here's my question, I have a django project and I want my function to access an sav file that has my machine learning model stored in it. Is it possible?
 
Functions are able to access files, yes. Go ahead and open it however you usually do.
 
2:17 PM
Yeah, that would otherwise be a weird response to a post
 
I am not able to access the file after including it in the project folder.what am i supposed to do?
 
Is the file where you think it is? Are you looking for it where it really is? Do you have the right permissions for the file?
 
I think it is pointless trying to interpret someone's intentionally unhelpful and snide comment especially when they didn't put enough effort to remove ambiguity.
 
friday cbg, everyone
 
cbg
 
2:20 PM
@user5444075 Sounds like a "current working directory" problem. If you do import os; print(os.getcwd()) inside your function, it should display the name of the folder that the function can natively read from.
 
@andr
 
If your file isn't in that folder, you can either move the file to that folder, or change your cwd to the folder that has the file.
Or supply an abolute or relative path that points to the right place
 
@user5444075 you can edit/delete messages for two minutes after posting
 
DSM
Friday morning cabbage for all!
 
cbg
 
2:26 PM
Am I suppose to put the file in a specified folder?
 
Some projects like to put their non-source-code files in a "resources" folder, or similar.
Not that doing so will automatically make your program able to find the file. If you can't find it where it is now, you probably still won't be able to find it if you move it somewhere else (other than the cwd)
 
@Kevin I do this, it makes for cleaner organization when the project grows.
I just assume every project I work on is going to spiral out of control into a 100,000 LOC behemoth.
 
jjj
@user5444075 Have you read this? It's quite well explained I think
 
Yes I have, and still not being able to access them.
 
I have a more YAGNI approach where I cram everything in one folder until it's ridiculous
 
2:33 PM
Is there an effective way to share venv's? This new project I'm working on is going to require extra dev support and I'd rather just share my venv than write a "how to set up your venv from scratch" document.
 
jjj
^ I believe you can share conda environments, not sure about venv
 
@jjj melon
 
jjj
watermelon
 
2:53 PM
cbg
 
cbg
 
OMG, I just made my life so much easier with sharing this conda venv
 
jjj
really glad to hear that :)
 
Problems keeping environments consistent prior to now, I gather?
There's always that one user that's still running Python 2.5 on an Etch-a-sketch
I saw a question that had a wrong answer, so I added a right answer, but then the first guy edited his wrong answer into a right answer that's even better than my answer ;_;
 
I have a meeting in an hour because an environment not working on recent installs.
 
DSM
3:06 PM
One of the first things I did at NumberFirm was sort out a consistent conda-based env for a production process involving numbers with many, many, many digits which was running off a guy's half-broken desktop. O.o
 
NumberFirm means business when it comes to numbers
 
@DSM at least 5 digits??
 
DSM
Indeed they had at least five digits.
 
the evolution of technology continues
 
As we know from Russian, it's "one, two, three, four, a lot"
 
3:11 PM
Whoops my right answer turned out to be a wrong answer. But the other guys' right answer is also wrong, so it's a wash. And anyway the whole post got hammered.
Hmm, is there a way to define a regex that matches any one character in a string I have assigned to another variable? Ex. If I have x = "!?." I'd like to make a regex that matches exclamation points, question marks, and periods.
I can't just do re.match(f"[{x}]", mystring) because that doesn't generalize to all possible values of x. For example, if x was "a-z", then the regex would match all lowercase characters, rather than just lowercase a and hyphen and lowercase z
 
re.escape should help
 
DSM
Can't you.. aargh, Kevin'd by vaultah, I had re.match("[" + re.escape("a-z") + "]", "abc") in the console :-(
 
Hasta la taco.
 
DSM
Intern just called me over to review his proposed solution to a problem an analyst had posed him, and not only had he broken it down correctly, he'd come up with an efficient approach which will also improve our code in other aspects. :'-)
 
3:22 PM
Oh wow, 14 seconds, this was fast. I was nearly sure that this question would already have an answer, but I was not sure what exactly to look for or how to better describe the problem. Thanks for pointing me to the answer! — Sentry 1 min ago
^^
 
good dupe job?
 
Is that a new personal best?
Maybe a world record, even?
 
My personal best is 9 seconds, IIRC. Time to jump into SEDE!
 
._.
 
Such comments are just so rare, that I always upvote those who write them
 
DSM
3:26 PM
I think I've closed some list multiplication and default mutable arg ones pretty quickly, but never that quickly. I can't even find the dup that fast, even when I know exactly what one I want.
 
Ah no, the best was 10 seconds...
 
Whaaaat, it's not even a single-digit number? You need to step up your game :P
 
3:42 PM
I can't tell you how many times I've stared at words like "proclivity" and not been able to see a misspelling because my brain refuses to pick up the difference between 'il' and 'li'. Thank you spellcheck!
 
we have a female name Lili, sounds like your bane ;)
 
re.escape appears to do the needful, thanks
 
@AndrasDeak You're right. That makes me iilL
 
4:03 PM
Is "Lili" a homophone with the name "Lily", which is to say, the two syllables are pronounced differently? That's a pet peeve of mine. Sean Bean should either pronounce his name "Seen Bean" or "Shawn Bawn". I can't stand the middle-of-the-road state we're in now.
Morphemes 👏 within 👏 a 👏 proper 👏 noun 👏 should 👏 be 👏 consistently 👏 pronounced
 
@Kevin Hungarian is phonetic, so the two syllables are the same. Then again I'd say "Lily" with two similar syllables, so...
 
Might be a regional thing.
 
I probably can't distinguish ɪ and i properly en.wiktionary.org/wiki/lily#Pronunciation
 
(we only have i, see kifli)
@AshishNitinPatil pineapples
 
4:09 PM
melons!
3 badges in a row (Enlightened, Nice Answer, Python tag) with a single upvote 8-)
 
I'm sure this has been asked before, but why is it cooking.SE and not Snack Exchange?
9
 
I got my "I play with pandas" sticker today. I'm very excited.
 
Why isn't that place more active? I might have to fix that.
 
^ please do
 
4:13 PM
Enter that place and topple its dark throne
 
DSM
inadvertent infinite is going in on my title-for-something list.
 
@DSM that should be the title of your title-for-something list
 
DSM
Heh eh eh.
I do collect a lot of them.
 
jjj
4:56 PM
rhubarb all, have a nice weekend
 
rbrb
 
5:11 PM
Took me a minute to figure out why Why does this for loop not work for the whole list? wasn't failing with an IndexError
 
5:42 PM
I forgot cbg earlier, so super-late-cbg -super-experience-cbg \o
 
cbg
 
cbg
 
TIL the project I was hammering away all week, was simpler than I thought. I wrote a generic function to handle every wide spread case, when all was needed was a simple pre defined function. Oh well on the plus side this function can handle multiple things in the future.... :\ On the downside I wasted 2 days trying to figure and cover cases....
 
@Kevin It's always fun when using list(range(n)) for toy data hides problems because the elements are the same or almost the same as the indices…
 
5:51 PM
Python devs, please add a parser warning at the beginning of the execution of every program that has seq[x] inside a for x in seq: loop
If you actually want to intentionally double-index, then use the --I-really-know-what-Im-doing flag
 
The "consenting adults" rule means Python defaults to --I-really-know-what-Im-doing-flag=True, but any linter worth its pip install should run your code as if --I-really-know-what-Im-doing-flag=False and provide a way to whitelist exceptions.
 
The "we're all adults here" principle should be enforced with photo ID
 
1 #!/usr/bin/env python3
2 # put a padlock on the gun cabinet
 
Mail three forms of state identification to the Python Foundation to receive permission to use eval within the next thirty business days
 
I think we could turn the background check into an automated achievements system.
Achievement unlocked: You wrote an import hook that can do the equivalent of eval without calling eval! You can now use eval in your programs!
 
6:00 PM
The authorities are already on their way
 
Achievement unlocked: You accidentally published that import hook to a PyPI project that's going to be deployed in the wild! You can now go to hell!
 
You used 80 characters on a line. Game over.
 
user reasks a question... close as duplicate doesn't seem right.
 
You called remove on a list in a loop. You have been eaten by a grue.
 
Place your hand in the Punishment Box to unlock your user account
 
6:06 PM
You tried to abuse the context manager protocol to build an unreadable DSL. The interpreter executable has been renamed from python3 to ruby. (Your pre-existing ruby interpreter is still available under the name mit-scheme.)
 
6:31 PM
exec
 
>>> s = "2+2*2"
>>> import subprocess
>>> import ast
>>> ast.literal_eval(subprocess.check_output(f"python -c print({s})").decode())
6
 
abarnert laying down the foundations of pymanji
@piRSquared two separate questions asking the same thing by the same user are bad. Closing one to leave the other to be handled as necessary is only natural.
 
Hmm, I may have prematurely hammered Tkinter 2.7- image won't show up in the window with .mainloop() [duplicate] because typically the photoimage bug occurs if the image instance goes out of scope before mainloop executes. But mainloop and the image are in the same scope here.
 
Yeah, the problem there is that the OP didn't add the label until after the mainloop exits.
The error message you get after running the program should've given it away, really. Not sure just how terrible the OP's debugging skills are
 
6:47 PM
So much time on SO and you're still not sure?
 
My heart still holds on to that faint hope that OPs aren't mindless zombies :(
 
some of them aren't
also unicorns are real
 
Well, first I get SyntaxError: invalid syntax because he left the asterisk out of from Tkinter import. If I fix that, then a blank window appears, because the label doesn't get pack()ed until after the mainloop. If i fix that, then nothing appears, I think because the PhotoImage constructor doesn't know what to do with a string argument unless you use the file named keyword. If I fix that, then it crashes because I don't think you can open pngs with PhotoImage.
 
I'm 99% sure that tkinter supports pngs, but I don't know if it's through PhotoImage
 
photos are usuall jpegs, so probably not
 
6:56 PM
Of course that's from the Tkinter Book, which hasn't been updated since GIFs were still a shiny new format except for that pesky patent problem, so it might be worth verifying that it's still true. But I'd bet it is.
 
I'm surprised tkinter doesn't throw an error then, if it really can't read that png file
 
Does it not throw an error? As Kevin pointed out, the OP's code isn't even going to get to the point of trying to read the file…
 
I'm sure they just MCVEd away the five lines that use PIL to come up with appropriate input ;)
 
Obviously the right solution is to use PPM for everything so this never comes up.
 
Just jumped in before I leave for the day. But just curious @Kevin you did an import *. Dont we usually recommend against that with Tkinter?
 
6:59 PM
The image isn't added to the GUI in time, but it is loaded before the call to mainloop, so there should've been an error
 
Im thinking of a convo from awhile back in here I believe.
 
Strange, I thought I just tried reading a png with photoimage five minutes ago and it crashed, but when I try it now, it works.
 
the official tkinter docs (tutorial?) contains star imports
 
Oh, it crashes on some pngs and not others. That's deeply weird.
 
If you fix all the other problems with the code, you get _tkinter.TclError: couldn't recognize data in image file.
 
7:01 PM
Yeah it does. I think that was also a complaint about the tutorial last time too.
 
@ZackTarr Yeah, but I wanted to jam out the quickest possible solution. I'll go back and recommend the better way.
 
But anyway, the image isn't loaded before the call to mainloop; it isn't loaded at all because of the other errors.
 
Sweet. I had just hoped in and saw that. Likely its not a big deal at all. But just recalled the last time we talked about it all.
But that is all. Have a great weekend everyone! Rbrb
 
Doesn't calling PhotoImage(whatever) immediately load the image? Is it a lazy operation?
 
3.14159 quatloos to anyone who can find tkinter documentation that describes what PhotoImage("python.gif") does, because it definitely doesn't load python.gif and display it
 
7:05 PM
Isn't tkinter infamous for not holding up to python's usual documentation quality?
 
1 - (0.999...9) quatloos if you can only find Tcl documentation
 
There is no relevant Tcl documentation, because PhotoImage doesn't just pass the arguments straight through as a Tcl string.
The source makes it pretty clear, though: the first positional argument is name, not file or data or anything else usable on its own.
 
Oh, name, that's useful :-|
 
I believe the Tcl string ends up something like photo $name {} -file "$path" where the name defaults to something like Tkinter-photo-123 if you don't pass one.
Tkinter might check for more than one of -file, -data, and whatever the other options are, but it probably doesn't check for zero of them, because it's perfectly valid (if useless for PhotoImage's purposes) to create an empty but named Tk image object.
 
wim
wtf yaml
 
7:13 PM
Ok, you've convinced me that empty named images are a potential use case. Therefore, I will add this to the "documentation fail" subsection of my tkinter_grievances.txt file, rather than "design fail"
 
wim
>>> import yaml; yaml.load("-versions: [3.6, '3.7', 3.6.4, '3.6.5']")
guess the output
 
Array of four numerical strings in an object? (I don't know yaml)
 
@wim *what the yaml
 
{"-versions": [3.6, "3.7", "3.6.4", "3.6.5"]}?
 
Empty named images are a potential use case for Image; I don't think they are for PhotoImage.
Anyway, can you call something a "fail" when there isn't even an attempt?
 
7:16 PM
I also don't know yaml, but it must be something wacky like a heterogeneous list, or else wim would not have asked this riddle
 
some of them are hopefully null
 
My guess is that wim is expecting the - to mark this as a dict rather than to be part of the key, or vice-versa, and it's doing the opposite.
(I'm not going to guess which of the two is right, I'm just going to guess that wim guessed it wrong, because he wouldn't have asked otherwise.)
 
wim
yeah so I thought I had a bug in johnnydep, or PyPI had a bug, but it was actually just yaml behaving "normally"
$ johnnydep sip --fields name summary homepage versions_available -o yaml
- name: sip
  summary: Python extension module generator for C and C++ libraries
  homepage: riverbankcomputing.com/software/sip
  versions_available: ['4.19', 4.19.1, 4.19.2, 4.19.3, 4.19.4, 4.19.5, 4.19.6, 4.19.7, 4.19.8]
compare TOML, which is sane
$ johnnydep sip --fields name summary homepage versions_available -o toml
name = "sip"
summary = "Python extension module generator for C and C++ libraries"
homepage = "https://www.riverbankcomputing.com/software/sip/"
versions_available = ["4.19", "4.19.1", "4.19.2", "4.19.3", "4.19.4", "4.19.5", "4.19.6", "4.19.7", "4.19.8"]
 
What are even those non-string version strings?
or does yaml make the quote marks optional?
 
Having quote marks only around the value that could possibly be a float is the opposite of what I expected
 
wim
7:21 PM
right?! ridiculous
 
Maybe the reasoning is "all these other ones definitely aren't numbers, so I can leave off the quote marks and you'll still know they're strings. But 4.19 is ambiguous, so I have to tell you it's a string explicitly"
 
wim
your reasoning about the bad reasoning sounds like good reasoning
 
Exactly: YAML tries to DWIM whenever possible, which means sometimes it ends up doing what only an insane person could mean because there's nothing a sane person could mean, instead of just raising an error.
 
I'm something of an expert at making post-hoc justifications of terrible decisions B-)
 
wim
YAML tries to DWIM (displease wim) whenever possible
10
 
7:24 PM
Also, whether 1.2.3 is ambiguous or a string depends on what types you've imported from the repository.
 
wim
@abarnert elaborate...?
 
Ah yes, the DeweyDecimal type
(hmm, this joke only works if the Dewey Decimal system uses more than one decimal point per book classification, and looking it up now I guess that's not the case)
 
Untagged nodes can be parsed as any type that's imported from the registry unless imported as bang-typed-only. The only builtin type that matches 1.2.3 is string, but if you registered some DeweyDecimalAsMisinterpretedByKevin type, it would be ambiguous.
 
So YAML is extensible in that way... Interesting.
 
Yes, that's one of the selling points of YAML.
Or one of the attractive nuisance points, if you've used it for anything nontrivial.
 
7:32 PM
Speaking of DWIM, is pandas always this annoying to work with?
>>> df
  Str1 Str2 Str3
0   OK    I   Go
1  Yes  NaN   Hm
>>> df.apply(lambda x: [1,2], axis=1)
0    [1, 2]
1    [1, 2]
dtype: object
>>> df.apply(lambda x: [1,2,3], axis=1)
   Str1  Str2  Str3
0     1     2     3
1     1     2     3
"The result is a list with exactly as many values as there are columns in the dataframe? Obviously the user wants me to unpack the list into the columns!"
 
@Aran-Fey wow that is disgusting
 
@Aran-Fey you had it coming at df.apply
 
@Aran-Fey yes, but please don't do that
 
Is that so? I see it used a lot. Monkey see, monkey do.
 
The documentation for df.apply really should have more warnings about how this is usually not what you want, instead of just the little note about how it may lead to duplicated side-effects because of the way pandas optimizes.
 
7:39 PM
Also it's usually very slow, is it not?
 
wim
collections.Counter.__or__ and __and__ are weird.
not sure on the use case there.
 
lists and arrays are special cased like crazy, if you dissect its bowels, you'll see. Another example is here
Answer courtesy wim
 
this PWIM
 
Indeed, it is slower than a loop, but not as slow as df.iterrows.
 
@wim Aren't they just union/intersection when looking at the Counter as a multiset?
 
wim
7:42 PM
yes
but when would you want to union counters instead of summing counters?
 
When you really are using it as a multiset rather than as a counter. If one multiset has 3 spams, and another has 5, the union of those multisets has 5, not 8.
 
You have a corpus of articles and want to find the word that's repeated the most in any one article. So you make a Counter for each article, union them together, and call max on the result's .items()
Or uh I guess max(c.items(), key = lambda t: t[1])
Ooh, or how bout max(c, key=c.get)
 
I'll bet that somewhere around 3.0 or 2.7/3.2, someone suggested that we should have a proper Multiset class, which was then rejected because it would be the exact same thing as Counter except for adding & and | operators, so it would make more sense to just add those operators to Counter and make it clear somewhere that Counter is the idiomatic way to do Multisets.
Using the same Counter object to mean both things at once can occasionally be confusing, but just don't do that.
 
> It was on display in the bottom of a locked filing cabinet stuck in a disused lavatory with a sign on the door saying 'Beware of the Leopard"
 
In the middle of the Counter docs: "The Counter class is similar to bags or multisets in other languages." Obviously anyone looking for a multiset will find it there, right?
 
7:48 PM
Having found three examples of poor documentation today, we are entitled to one (1) kewpie doll from the PSF
 
Later on in the docs: "Several mathematical operations are provided for combining Counter objects to produce multisets (counters that have counts greater than zero)… Intersection and union return the minimum and maximum of corresponding counts" and then an example showing that. So once you've found it, the documentation seems pretty nice, it's just a matter of finding it in the first place.
 
Example #2 was from a third party library but it's more about encouraging community participation than facilitating finger-pointing
 
Looks like the change was in 3.3, not 2.7/3.2 as I guessed.
 
FWIW googling "multiset site:docs.python.org" gives me collections as first hit
not that I'd ever think that there's an stdlib solution for this
 
@AndrasDeak Probably the set of people who know that what they're looking for is called a multiset and the set of people who know how to site-search docs have a lot of overlap…
But then they're both pretty small sets, as SO proves.
 
7:51 PM
:)
 
Knowing that a multiset is a mathematical concept that exists may be a substantial task for some portion of the community, to begin with
 
Is it okay to ask which moderator handled your flag in the event that you're really grateful to them for the way they handled it?
 
Whoops, beaten. But multisets teach us that the same object can exist harmoniously with other copies of itself
 
well, that's too bad
 
7:52 PM
if you object to a mod action you can raise it on meta but "thanks kind moderator" questions sound uncanny to me
 
object? No, I wish I could sent them a bouquet of roses
 
I can't speak for mods but handling things is kind of their job :P
 
Yeah but they could make a piss poor job of it, which the mod in this particular case did not. Hence the gratitude :)
 
I've seen suboptimal mod actions, I'll grant you that
 
You could try inviting them to a chat, or finding if/where they lurk and @ them
oh, nvm
 
7:58 PM
:D
 
I can't read gud
goes back to coffee
 
coffee is always a good fallback
 

« first day (2729 days earlier)      last day (2219 days later) »