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)
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
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)
@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
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
ahah this company provides template for internal Python repositories with a classic directory structure, except that src is considered to be a Python package
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...