Earlier quoted context omitted.
Wait, how does that work? As far as I can see from the documentation, it can only serve on localhost, which to my understanding is only accessible from the single device it was launched on.
I think you must have misread the documentation [1], which says: "By default, the server binds itself to all interfaces." [1] https://docs.python.org/3/library/http.server.html
CLI tools hidden in the Python standard library
71–80 of 160 posts
Re: CLI tools hidden in the Python standard library
#72Speaking of hidden Python tools, I'm a big fan of re.Scanner[0]. It's a regex-based tokenizer[1] in the `re` module, that for reasons is completely missing from any official documentation. You give it a pattern for each token type, and a function to be called on each match, and you get back a list of processed tokens. Importantly, it processes the list in one pass and ensures the matches are contiguous, where a naive…
Re: CLI tools hidden in the Python standard library
#73There is one problem with those: Security. Using modules (even if they are in the standard library) on the command line lets malicious code in the current dir take over your machine: https://twitter.com/marekgibney/status/1598706464583028736
> Seth pointed out this is useful if you are on Windows and don't have the gzip utility installed.
Okay, so instead of installing gzip (or just using the decompressors that aren't the official gzip utility but that do support the format and already ship with Windows by default[1]), you install Python...?
Even if the premise weren't muddy from the start, there is a language runtime and ubiquitous cross-platform API already available on all major desktops that has a really good, industrial strength sandbox/containerization strategy that more than adequately mitigates the security issues raised here so you can e.g. rot13 without fear all day to your delight: the browser.
1. https://news.ycombinator.com/item?id=36099528>
Re: CLI tools hidden in the Python standard library
#74> I thought this might provide a utility for generating random numbers, but sadly it's just a benchmarking suite with no additional command-line options: I had the same experience with the tkinter ones - I thought they might be like zenity, a way to build simple UI elements from the command line. But they mostly just show simple non-configurable test widgets. The colour chooser could be helpful though.
So random and math are somewhat usable that way
$ python -m fire random uniform 0 1
0.5502786602920726
$ python -m fire math radians 180
3.141592653589793
$ python -m fire math e
2.718281828459045
Just running $ python -m fire random
will give you a nice "manpage" for your module as well.Re: CLI tools hidden in the Python standard library
#75There is one problem with those: Security. Using modules (even if they are in the standard library) on the command line lets malicious code in the current dir take over your machine: https://twitter.com/marekgibney/status/1598706464583028736
I find the entire premise of the post to be pretty baffling. > Seth pointed out this is useful if you are on Windows and don't have the gzip utility installed. Okay, so instead of installing gzip (or just using the decompressors that aren't the official gzip utility but that do support the format and already ship with Windows by default[1]), you install Python...? Even if the premise weren't muddy from the start, the…
Re: CLI tools hidden in the Python standard library
#76Re: CLI tools hidden in the Python standard library
#77There is one problem with those: Security. Using modules (even if they are in the standard library) on the command line lets malicious code in the current dir take over your machine: https://twitter.com/marekgibney/status/1598706464583028736
Re: CLI tools hidden in the Python standard library
#78There is one problem with those: Security. Using modules (even if they are in the standard library) on the command line lets malicious code in the current dir take over your machine: https://twitter.com/marekgibney/status/1598706464583028736
iirc this is one of the things earmarked for a hypothetical Python 4, making -P the default. It's also one of the many relatively well-known (security) issues in Python that don't get addressed for a surprising amount of time. Others in the same vein would be stuff like stderr being block-buffered when not using a TTY, no randomized hashes for the longest time, loading DLLs preferably from the working directory, std*…
Re: CLI tools hidden in the Python standard library
#79I use http.server all the time, particularly as modern browsers disable a bunch of functionality if you open file URLs. Had no idea there was so much other stuff here!
I use miniserve (`cargo install miniserve`). You also have available `npx serve`.
Re: CLI tools hidden in the Python standard library
#80Earlier quoted context omitted.
Especially now that they are on a crusade against their own stdlib. They regret including most modules… it seems they regret making python altogether instead of sticking with C? :D
> They regret including most modules… it seems they regret making python altogether instead of sticking with C? :D I also find it odd. Python would probably be a little known language without the huge batteries included by default. It's invaluable when you're working in a environment where you can't fully control what is installed, what is the case of most people at work. I believe this crusade endangers the language…