« first day (3623 days earlier)      last day (1319 days later) » 

2:20 AM
I'm returning to python after (quite) a few years. What's the best way to manage packages/deps? Back when, I used pip3+requirements.txt
 
 
5 hours later…
@bsapaka flit/poetry with a pyproject.toml. Unless you need to run arbitrary code during installation, in which case setuptools and setup.py
 
@bsapaka virtual environments are everywhere, there is no good reason not to use one. Some people still use pip+requirements.txt, and for simple projects that's good enough. But package managers like poetry and flit make packaging/publishing a lot more enjoyable
also, kevin'd
@Aran-Fey at least with poetry, you can bind build-time scripts. otherwise you wouldn't be able to build projects that use cython with it.
 
oh, neat
 
 
1 hour later…
8:12 AM
did anyone else get spam flag notification from the Javascript room?
don't remember being a mod :-p
or is that not a requirement to "validate" spam / offensive flags?
 
It's for everyone over 10K I think that gets them
 
oh ok
 
And yes, I got 3 on someone we're well-acquainted with. I'm hoping they stay over in that room :P
 
9:06 AM
Aww, it looks like the close vote leaderboard only counts votes that go through the queue :(
 
"MisterMiyagi 102"
Yes, definitely just the queue :P
 
Gah, you beat me on 34 :P
 
@roganjosh yes. You can see all close votes in your votes tab
 
Yeah, I hunted that down to make myself feel a bit better; 6,271 votes there
 
Gah, you beat me on 3,491 :P
 
9:21 AM
ha, I've got 6231
 
Too close for comfort - to the main feed I go! <flies away> (I'm not gonna try compete with your downvote count, though :P)
 
Hm, does the vote tab only include votes on undeleted content?
Can't believe I've rained down JUDGEMENT on the mortal realm only about 1k times
 
@MisterMiyagi the up/down votes yes. The aggregate on the bottom no.
 
there's an aggregate? oO
This UI is confusing...
 
Yeah, you can see the aggregate for other people too, but not a breakdown. It's at the bottom of all "Activity" tabs - that's how I know how many downvotes Andras has cast :)
 
10:11 AM
After trudging through the third py2 script I've inherited yesterday, I'm really wondering how anyone could ever have liked that language... :/
such uncivilised times...
 
it's easy if you have no idea about bytes vs strings because you live in an ascii world
 
future generations will look back and wonder how people survived in these crude times before the f-string age...
@AndrasDeak yes, that too is a topic I'm afraid of. The core module used by the scripts is not realistically runnable on my machine. What horrors are lurking at the edge of my IDE, waiting to pounce on me in production?
Is it going to be a type mismatch? A list-instead-of-set-like-view? Bytes in bytes in bytes as str?
Tune in again in a few hours when I've mustered up the courage to try...
 
10:30 AM
Hm, I'm pondering whether I've actually come across a use-case that might benefit from asspressions:
n = 12
while True:  # remove trailing zeroes in binary of n
    div, mod = divmod(n, 2)
    if not mod:
        n = div
    else:
        break
print(n)
Does someone with Py3.8 installed, and also with actual experience in asspressing, see a chance to cram the body completely into the while condition?
 
10:46 AM
scratch that idea with a big, fat SyntaxError: cannot use assignment expressions with tuple
 
10:58 AM
cabbage
 
cbg
 
Has anyone built an enterprise-level system in Python using something like a Clean Architecture by Robert C. Martin.
 
11:49 AM
Are you asking whether someone in here as done so, or whether someone in general has?
Python is used for enterprise systems, if that's a useful answer to you.
 
12:19 PM
I'd forgotten how much I loved the gradual build up and dramatic ending in Death is the Road to Awe. Thank you YouTube for digging that up from years ago. Now I want to watch The Fountain again
 
12:36 PM
@MisterMiyagi Someone here, so that I can get some guidance
 
It might be easier to ask whatever you are interested in, and see whether people have useful answers.
 
@MisterMiyagi not sure if I understood the algorithm properly but while ((n:=t[0]) if not (t:=divmod(n,2))[1] else None):... works?
 
@smci it's very unfortunate that that's the current state of affairs :(
@Pax This is for anyone who'd like to join. It's just a meet-and-greet so that we get to meet people that we spend as much time with (as we do) in a time when we're all forced to stay indoors (because COVID-19)
 
12:55 PM
@python_learner I've arrived at something similar using while (div_mod = divmod(n, 2))[1]: n = div_mod[0] but the indexing kinda hurts readability. Being able to unpack in normal assignment really helps.
 
you missed the : in := :p
talk about readability
i give up editing this, that :p was a smiley
 
1:16 PM
That seems pretty weird. The issue is action_2 = action_1.copy not actually calling the method - though fixing that alone doesn't quite get the desired output. But it looks like pandas will actually take a function as a column header and only crashes when you try to actually print the df
I'm inclined to think there's a bug in pandas there to allow that to work in the first place?
Actually, I don't even know what kind of beast it created because I can't see it :/
 
1:29 PM
@python_learner ah, thanks. := isn't part of my muscle memory yet.
 
nm, it looks like a weird side effect of indexing by callable
 
have you tried burning it with fire lately?
 
Gotta wait for the holy water to dry off first
I'm still in two minds whether this is fringe-enough to be considered a bug to raise for them. The result of what it allowed me to do is utterly bizarre, unusable and gives a nonsense traceback of TypeError: unhashable type: 'list' not showing where the error even originates - print() being the culprit was just my guess because it mentions the formatters module
 
IMO the proper answer is to use a static type checker.
Explicitly guarding against all such errors is futile and just creates absurd technical debt.
 
1:45 PM
Problem being that they appear to allow callables, so I'm not even sure how they would check that. That's part of the reason I'm hesitant because I'd have to pass the whole issue off to them; I can't begin to work out whether this highlights something unusual, or it's just "well, you wrote the broken df"
I'll take some more time staring out the window into the middle-distance, looking pensive. Then I'll know what I must do.
 
It is basically the grown up version of "JSON parser does not handle <non JSON>". One that was abandoned in the woods as a kid and had to eat Bambi in order to even live long enough to grow up.
 
@inspectorG4dget I am interested. When is it
 
user11006952
2:05 PM
> So that we get to meet people that we spend as much time with (as we do)
 
user11006952
Right. That's what I was hesitant about since I don’t visit the chat regularly. I think the last time I sent a message here was months ago.

Actually the notification of hangouts was really good timing. I just came from a DataScience workshop / Hackathon (Vancouver DataJam) and really liked my experience there. I wanted to do more of that (meeting other professionals + learning from them) And lo, I saw the starred message re: hangouts.

I like to listen to the talking points but I don’t have a lot of experience about those so I won’t be able to contribute much. I’m hoping that’s still okay?
 
^ same as that
 
user11006952
> ...Hackathon** (Vancouver DataJam)
 
user11006952
more accurately "hackathon-like"
 
The chat isn't about the talking points btw; they were added on my suggestion. It's only because it's hard to get things moving if there's a bunch of people that don't know each other sat in a chat room.
So, in answer to that question, it's absolutely fine to have no experience with them
 
user11006952
2:10 PM
@roganjosh Right. I'm not expecting a workshop or conference-like session, of course. I assume I'd be hearing people's ideas and opinions here and there about certain things in Python.
 
user11006952
@roganjosh Great!
 
Well, I should say that I discussed the idea of suggested topics with inspectorG4dget. They've done all the work in setting things up and collecting the suggestions
 
2:49 PM
stackoverflow.com/q/63922459/4799172 dupe (or a better canon if you know one off-hand)
 
Exactly. There's no set agenda. And for what it's worth, those talking points may never be looked at. We might just end up talking about pizza rat
@roganjosh Hammered
 
Thanks :)
 
   ,
  /(  ___________
 |  >:===========`
  )(
  ""
 
 
2 hours later…
4:27 PM
@Aran-Fey I stupidly thought I'd heard all his recordings but I've just come across the hitch archive channel. Currently listening to free speech but a scan of the channel suggests there's a lot of videos that haven't come up in my searches before
 
4:45 PM
Five demerits to every emergency contact form with a "relationship" dropdown that doesn't make it completely clear which direction the reference is pointing
"Name: Steve Kevinson. Relationship: Uncle" could either mean that I am the uncle of Steve Kevinson, or that Steve Kevinson is my uncle
 
it would probably default to the contact being the uncle
 
I blame the neurotypicals, they just love ambiguity and nuance
Site: "click here to launch the mandatory widget safety briefing"
[I click. Nothing happens]
Me: "hmm, maybe there's a bug in the javascript? I'll check."
function openWidgetBriefing(){
    //window.open("");
}
Well, it's technically not buggy, it's doing exactly what it was told to do
 
5:06 PM
@MisterMiyagi If you just use % and >> to do what divmod does, is this what you were looking for?
while n != (n := (n if n % 2 else n >> 1)):
    pass
 
5:36 PM
assexps seem tricky here because they kind of make the while behave like a do-while. It performs one more assignment than you'd like it to.
Hmm, maybe something like:
>>> n = 12
>>> while 0 if n % 2 else (n:= n>>1):
...     pass
...
>>> n
3
 
Good night guys! :)
 
night, Tanish
 
Sleep tight
 
@Kevin :D
@AndrasDeak :)
 
@Kevin Ha! a do-while using while 0 if <end condition> else <asspression to update end condition>: pass - a one-liner loop-and-a-half. That while 0 is definitely a head-scratcher when you first look at it.
 
5:50 PM
I'll quietly add it to my underhanded programming techniques dossier
 
, 2nd call Does Python automatically flush its buffer when calling seek and/or read operations following a write? was wrongly closed into a Windows-only question. (If anyone has a better dupe, please post it there (rather than here)
@inspectorG4dget and everyone: please vote to reopen. Had hoped MarkRansom would come here to discuss.
 
6:07 PM
@PaulMcG I was hoping to use divmod to avoid having to use % and // separately.
 
MisterMiyagi what's your opinion on my reopen request above? I'd appreciate if people help.
Needs details - question isn't well-defined for multiple sentiment-carrying words. Also, borderline seeking tutorial. stackoverflow.com/questions/63924951/…
 
>>> while 0 if not ((a,b) := divmod(n,2))[1] else (n := b):
...     pass
...
  File "<stdin>", line 1
SyntaxError: cannot use named assignment with tuple
Dang
 
it's 2020 and parsers still have weird restrictions like these smh
sometimes it really shows that computers are still a pretty new thing
 
Our descendants will look back and chuckle at our lack of tuple named assignment expressions
>>> n = 12
>>> while 0 if (x := divmod(n,2))[1] else (n := x[0]):
...     pass
...
>>> n
3
Doing it without x is left as an exercise to the reader
Alternatively, proving it can't be done without x
 
6:46 PM
@MisterMiyagi In a race, I'll bet divmod loses because of the function call.
 
Most numbers are not divisible by four so on average you're doing 1 or 2 iterations, so the total number of calculations is about the same either way
 
7:23 PM
(scribbles on envelope) Approximately 75% of them.
 
@PaulMcG yeah, it's abysmally slow compared to the operator variant. Takes about twice as long
 
8:13 PM
stackoverflow.com/q/63918194/4799172 dupe. I did a second scan of Spyder; I'm pretty confident it doesn't exist
 
8:45 PM
"Things like it may have been asked (and answered) 1000 times before, but if this guy wants to know why his code doesn't work, what is he supposed to search for...." my favourite objection-quote to date. They can take their pick?
^ unrelated to my cv-pls request. Just a big foot-gun as an argument
 
9:12 PM
stackoverflow.com/q/63927375/4799172 the OP seems pretty receptive and it's a big edit. I think it can be answered now with a little more enquiry
 
@Aran-Fey thanks for the recommendations! poetry looks well supported. I dabbled in pipenv yesterday but I think I'll switch over
 
 
1 hour later…
10:25 PM
hey guys, not sure if anyone is familar with smtplib and emails. in my sent email acct im able to see the email successfully sent to receiver. however its not reaching the recipient unless i manually go into my account and forward from my sent box
so it doesnt seem like the code is faulty as the recipient receives the message once i manually forward what was already automatically sent
oh got it
its in spam
now why is that
 
We can't know that; it could be for a number of reasons. I'm currently talking to a company and all of their emails just go straight to my spam folder
 
cbg
 
Maybe it's the domain they send from, maybe it's hotmail's checks (I'd really like to leave but I have such a nice email address)
 
true. i suppose i can have all recipients add said email acct to their addressbook to prevent
hahah
wow, havent seen a hotmail domain in years
 
... I'm getting old, it seems
 
10:31 PM
i was wondering if there is anyway to ignore a type hint, im using a lib that that parses a tsv file but it uses type hinting to force a file path to read (it uses a with open to actually do the reading). This is annoying because I have my tsv data in buffer
 
@jamest Take your new fandangled magic elsewhere
 
But, on a serious note, I don't think it can be answered here
 
very fair. feel free to clear my messages. ive solved with your assist
thanks @roganjosh
 
@Skyler So you want to pass a file-like object to that function rather than a file path? Is that what you're saying? Because that doesn't really have anything to do with type hints
 
10:34 PM
I'm not going to clear them unless that's what you really want, @jamest. There's nothing wrong with what you asked :)
 
i might just be misunderstanding the error somewhat upon rereading it after what you said
TypeError: expected str, bytes or os.PathLike object, not _io.StringIO
let me try 1 thing really quick
 
The function simply doesn't accept file-like objects as input, type hint or not
 
ha touche
 
Removing/ignoring the type hint won't help, you have to rewrite the function
 
then what exactly is the bytes that it accepts
 
10:39 PM
I don't see it accept any bytes objects
Well, it does, it's just not documented
 
hmm, so stringIO seems to be treated like an already open file with regard to with statements
I'll give ByteIO a shot and see if that works first
 
It doesn't. You can't open a BytesIO just like you can't open a StringIO
 
so if it accepts bytes objects what exactly does that mean I can do
ill admit my knowledge of different ways to buffer is limited
since this is suppose to be part of a pipeline its a bit of an actual headache to have to throw everything to a file and then actually read it
 
10:59 PM
Does this help?
 
You can either rewrite the function to accept file-like objects, or you can monkeypatch open
 
They can't re-write the library function, though?
 
Make a pull request *shrug*
 
Thanks Josh, that was actually the answer I was looking at when I first mentioned BytesIO, I was adapting my stuff to do that when he said BytesIO would not open there so I stopped for a minute to try and find reading about how bytes and ByteIO were different
btw, that same idea wouldnt work with SpooledTempFiles since you technically still end up passing a path to the tmp file right (the class I'm talking about here docs.python.org/3/library/… )
the answer under that is actually quite interesting too
3
A: StringIO and compatibility with 'with' statement (context manager)

hjdThis one is based on the python doc of contextmanager It's just wrapping StringIO with simple context, and when exit is called, it will return to the yield point, and properly close the StringIO. This avoids the need of making tempfile, but with large string, this will still eat up the memory, s...

looks almost like an iostream mirror of what tempfile did in a way
 
mmm. Speed test that against dumping to a file and re-loading
I don't know why there is no simple way to do this, though. I have similar issues
Why can't we have a fake file in memory that supports open(), close() et al.?
sqlite3 supports it, and that's bundled as standard
 
11:12 PM
Well, because the whole point of open is to take a path as input and return a file, right?
This is kind of like asking why we can't pass a dict to json.load
 
but i thought one of the points of open is it accepts file like objects
not just files
 
You mean paths? It only accepts paths (and path-likes)
Oh man, I'm kind of looking forward to writing code after the python 3.5 EOL (which is due right about now, I think)
 
ended up getting a very similar error TypeError: expected str, bytes or os.PathLike object, not _GeneratorContextManager
 
@Aran-Fey it'd only be a thin wrapper around the thing in memory to "pretend" that you opened it, though, woudnd't it?
 
the generator was directly called in the with open it used as an example but I wonder if I can just directly pass what it normally yields...
 
11:27 PM
Then you could call .open() and it just returns itself. But hey, now it works with a lot of APIs
Or, I'm being dumb
 
@roganjosh Depends. How would open behave if you pass it a file object and a couple of keyword arguments? open(a_text_file, newline=''), open(a_binary_file, 'rb', encoding='latin1'), etc etc
 
mmm, fair enough. I still think there's a better way than we currently have. I've faced the same annoyance as Skyler of "oh, I'll have to dump this to disk and re-read it"
 
I actually don't think there's a good solution that automagically makes every function accept both file paths and file-like objects. They definitely could make it easier to work with path-like objects though, because at the moment you have to have an if isinstance(path_or_file, (str, bytes, os.PathLike)):, with extra branches for when os.PathLike doesn't exist (i.e. python 3.5)
 
11:45 PM
I don't think it has to? It need only support the same interface of file objects
 
It doesn't have to have that if statement, you mean?
Writing code that explicitly supports both files and paths is the only real solution I think
 
I'm suggesting that I don't think it would be too bad to have a new object that held the file contents and can support open() etc. But I don't know anything of language design
 
I just realized I have written an open-like function that simply ignores all extra arguments if you pass it a file-like object... that library probably needs a redesign
 

« first day (3623 days earlier)      last day (1319 days later) »