Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Jan 12, 2022 17:24
@Aran-Fey you can inherit from multiple base classes with __slots__ specified — but only if all but one of the bases has __slots__ set to an empty tuple
Oct 28, 2021 10:24
@AndrasDeak thanks!
Oct 28, 2021 09:56
On a happier note: this baby just got his first bugfix merged into cpython!
Oct 28, 2021 09:48
You can currently only bind a TypeVar to another TypeVar if the TypeVar it's being bound to is itself already bound... If that makes sense
Oct 28, 2021 09:47
Right, yeah, for that kind of usage you'll have to have the return type as Any rather than a TypeVar R, since there's no support for higher-kinded TypeVars currently ☚ī¸
Oct 28, 2021 09:38
@MisterMiyagi can I see how you're using the typevar?
Oct 28, 2021 09:38
@AndrasDeak indeed. Left over from an earlier experiment in the playground.
Oct 28, 2021 09:37
@MisterMiyagi oh that's fun
Oct 28, 2021 09:36
"preferable"... Well, better for this use case, if I understand the use case correctly
Oct 28, 2021 09:35
@AndrasDeak using an ellipsis for the parameters is preferable to Any, as Any can only represent a single parameter, whereas ellipsis in a Callable can signify "any number of parameters of unknown types"
Oct 28, 2021 09:33
@MisterMiyagi yeah. I think this is the best that's currently possible mypy-play.net/…
Oct 28, 2021 09:28
@MisterMiyagi ParamSpec isn't fully supported by Mypy yet, there's an open issue about it 😕
Oct 14, 2021 11:24
Yeah -- just annoyed me that somebody would take the trouble, and it was clearly serial downvoting given that all 3 were downvoted simultaneously. So I flagged. ¯\_(ツ)_/¯
Oct 14, 2021 11:22
@CodyGray Fair!
Oct 14, 2021 11:22
It was more that it was <every question I had ever asked> rather than <-6 reputation>
Oct 14, 2021 11:20
@CodyGray Hmm, was it automatic? I remember my rep score going down by 6 for a few days before my flag was resolved. (Not that it matters, it's all resolved now anyway!)
Oct 14, 2021 11:16
@roganjosh Ahhh, this explains why, when somebody serially downvoted me one time (for some unknown reason), they only downvoted my questions (of which there are three), rather than my answers (of which there are many more). People really do care too much about internet points if they're not even willing to spend them to satisfy an unspecified vendetta...
Oct 11, 2021 17:50
@Aran-Fey nice!
Oct 11, 2021 17:50
@AndrasDeak There was one just now, and I was surprised to see it wasn't on the canonicals list. But fair point — I can't say I've seen that many dupes :)
Oct 11, 2021 17:44
Could this question maybe be added to the canonicals list? The answer from @Michael0x2a is excellent. stackoverflow.com/questions/39740632/…
Oct 11, 2021 10:58
@Aran-Fey I'm tempted to file a bug report arguing there's a missing comma, but they'd probably say it would break backwards compatibility to add it in
Oct 8, 2021 15:00
Thanks so much for the debugging help @Kevin! Seems like some git weirdness was to blame discuss.python.org/t/struggling-to-build-python-on-windows-10/…
Oct 8, 2021 14:59
Update: I have succeeded in building CPython on Windows. Never let them tell you you can't achieve your dreams.
9
Oct 8, 2021 11:57
Greater London is foggy af today
Oct 8, 2021 11:57
Boo
Oct 8, 2021 11:56
I'm alright, doing okay! It's a grey and rainy day here in the UK, but hey
Oct 8, 2021 11:55
@JonClements thanks!
Oct 8, 2021 11:55
The fun thing is that you can't add __slots__ to an already-defined class, so in order to auto-generate slots, the decorator chucks the class you've defined in the trash can and dynamically makes a new one just like it that has the specified slots github.com/python/cpython/blob/…
Oct 8, 2021 11:49
@JonClements yeah probably. Wasn't a rebuttal of your point, just a tangential nugget of information!
Oct 8, 2021 11:49
It's always been possible to manually specify __slots__ in a dataclass, like they're doing in ^that question, though in <=3.9 it breaks the dataclass if you try to specify a default value for an attribute, since you can't have a class attribute with the same name as a slotted attribute, and dataclasses use class attributes as a mechanism for giving attributes default values
Oct 8, 2021 11:43
@JonClements 3.10 dataclasses have an option to auto-generate __slots__, which I'm surprised hasn't been advertised more
Oct 7, 2021 19:02
^As in, it did have to download the lbffi dependency again, but proceeded to fail with exactly the same error following that
Oct 7, 2021 19:01
Also tried deleting the libffi folder so that it would have to download the necessary dependencies again; had no effect
Oct 7, 2021 19:00
Fails with exactly the same error with Visual Studio 2017...
Oct 7, 2021 19:00
@Kevin Nah your gut was right.
Oct 7, 2021 17:25
We shall see if it makes a difference
Oct 7, 2021 17:24
Have uninstalled 2019 version, am 2/3 of the way through installing 2017
Oct 7, 2021 17:24
Too late
Oct 7, 2021 16:33
Reckon it's worth the hassle?
Oct 7, 2021 16:32
Ew it sounds like it is definitely not advised to attempt to install Visual Studio 2017 if you have Visual Studio 2019 already installed. So I'd need to uninstall Visual Studio 2019 first in order to try using Visual Studio 2017.
Oct 7, 2021 16:20
@Kevin Really appreciate it!
Oct 7, 2021 16:17
Apparently
Oct 7, 2021 16:17
I also have libffi-8.lib files in cpython\externals\libffi\arm32, cpython\externals\libffi\arm64, and cpython\externals\libffi\win32
Oct 7, 2021 16:16
@Kevin Hmm I don't think so? I've only tried to build twice, and got the same error both times.
Oct 7, 2021 16:15
@Kevin But my libffi-8.lib is in cpython\externals\libffi\amd64 rather than a .libs directory
Oct 7, 2021 16:14
Ahhh. Looks like I have a file called libffi-8.lib
Oct 7, 2021 16:10
@Kevin Doesn't look like it.
Oct 7, 2021 16:10
@Aran-Fey True, but I assumed that wouldn't matter? Can try installing Visual Studio 2017 I guess, that's a good point
Oct 7, 2021 16:07
Should be 3.11 alpha 0 unless something very strange is going on
Oct 7, 2021 16:05
Main branch I believe, so 3.11