Python

Room rules: sopython.com/chatroom Code formatting guide: tinyu...
Nov 17, 2022 12:00
Right
Nov 17, 2022 11:59
Can't you capture x by reference?
Oct 15, 2022 18:51
big haha
Oct 12, 2022 16:24
Obviously
Oct 12, 2022 16:12
Try converting tuples to lists
Oct 9, 2022 16:27
Thanks for the suggestion, I'll probably use a file-like object. download_file_from_http_api(url) will likely have to return something like AsyncFileStream or SyncFileStream depending on its type (i.e., async or plain)
Oct 9, 2022 16:23
Nah, thanks :) I think I've done something similar in the past
Oct 9, 2022 16:07
Another option is to use a handy function get_file_size_from_http_api(url) and call it before download_file_from_http_api(url) (which would then need to return just the file-like object/iterator), but this seems wasteful
Oct 9, 2022 16:05
If you have a function like download_file_from_http_api(url) that should return contents of a remote file in a streaming manner and also somehow let the caller know the size of the file (based the content-length header; say, to let the caller display a progress bar), what return value makes the most sense? I could think of a file-like object with the content_length attribute, a chunk iterator with the content_length attribute, and a tuple of (chunk_iterator, content_length)
Oct 6, 2022 18:37
I propose b = print(...)
Oct 5, 2022 12:45
Maybe even offer my recommendation of a flawed text editor that I personally use
Oct 5, 2022 12:44
@Aran-Fey I also came prepared to argue about it
Oct 5, 2022 12:40
Logged in to say that both are bad
Sep 27, 2022 16:45
And I was about to suggest that they use a dry soft piece of cloth for wiping
Sep 27, 2022 16:42
Dangerous advice
Sep 23, 2022 16:27
@KarlKnechtel nope this file is two years old
Sep 23, 2022 16:23
@KarlKnechtel it's a snippet of what is running in production in this company right now. The context: get the list of 5-tuples that represent regex rules with certain associated values, keep the regex rule and one of the values, but gather them in reverse order
Sep 23, 2022 16:10
Package this into your src package and ship it!
Sep 23, 2022 16:08
Very strong Python culture here
Sep 23, 2022 16:07
patterns = list(
    map(
        lambda rule: [[rule[2]][0].replace("\\", "\\"), [rule[1]][0]],
        rules,
    )
)
Sep 22, 2022 17:27
Just one of those options is okay to do
Sep 18, 2022 17:52
Can't be worse than poetry
Sep 14, 2022 18:00
I dislike functions with import statements inside them so much :( Because one of the main use case for them that I've noticed is to avoid circular imports
Sep 14, 2022 10:38
But yes, why not use a class
Sep 14, 2022 10:37
I wonder how outdated this is now stackoverflow.com/q/32611619/2301450
Sep 12, 2022 15:28
I guess I edited the message too fast. Yes, that's the reason :/
Sep 12, 2022 15:27
Nope
Sep 12, 2022 15:20
Does SO chat send a new message for each edit? It does Nope, then what happened there?
Sep 12, 2022 15:19
"Mr developer, do you want to run a script? Do python -m src.script"
Sep 12, 2022 13:26
CI comment: # Code quality check, CI action: mypy --package src 🤡
Sep 12, 2022 13:20
And they treat it as package, force-calling mypy -p src in CI and insisting that developers use absolute imports (from src.module import name)
Sep 12, 2022 13:19
ahah this company provides template for internal Python repositories with a classic directory structure, except that src is considered to be a Python package
Sep 12, 2022 12:29
type(dict2[key] == dict) will usually evaluate to bool
Sep 12, 2022 10:35
and type(dict2[key] == dict) oof
Sep 8, 2022 15:24
Where do people learn to use hash in this fashion
Sep 1, 2022 11:17
I often do ' '.join(text.split())
Aug 26, 2022 12:04
The terms foobar (), foo, bar, baz, and others are used as metasyntactic variables and placeholder names in computer programming or computer-related documentation. They have been used to name entities such as variables, functions, and commands whose exact identity is unimportant and serve only to demonstrate a concept. == History and etymology == It is possible that foobar is a playful allusion to the World War II-era military slang FUBAR (Fucked Up Beyond All Repair).According to an Internet Engineering Task Force RFC, the word FOO originated as a nonsense word with its earliest documented use...
Aug 24, 2022 14:19
So they shouldn't behave that differently :P
Aug 24, 2022 14:18
_sitebuiltins.Quitter raises SystemExit, just like sys.exit
Aug 24, 2022 14:16
> They are useful for the interactive interpreter shell and should not be used in programs.
Aug 24, 2022 14:12
I've always wondered why people use exit instead of sys.exit, but never asked them. quit is even weirder :(
Aug 24, 2022 14:11
@NordineLotfi the built-in quit function?
Aug 21, 2022 23:01
Could just pin that message
Aug 20, 2022 13:12
Isn't that super common in graphics systems
Aug 20, 2022 01:50
In general, I would say yes. Here are the rules of this room though, just in case sopython.com/chatroom
Aug 13, 2022 23:56
And that's the reason I didn't make them into a PR
Aug 13, 2022 23:52
I have no experience developing ST color schemes, so what you're seeing is a quick and dirty collection of hacks that happen to work for me
Aug 13, 2022 23:51
I didn't know how to make the background transparent, so I simply shoved an invalid value there :D