5 ms·
Summary: The author wishes that the third-party requests module were part of the Python standard library (ignoring the wishes of the person who wrote the reque
by raymondh 13y ago
Summary: The author wishes that the third-party requests module were part of the Python standard library (ignoring the wishes of the person who wrote the requests module).
The title is link bait. The "batteries" work fine - some are venerable, but they are well tested and documented.
The author ignores stellar parts of the standard library such as: collections, itertools, contextlib, functools, itertools, sqlite3, hashlib, struct, json, elementtree, etc.
Essentially, the author is bashing the entire standard library because the urllib modules are somewhat dated. IMO, The rant is not worthy of being on the front page of Hacker News.
- d23 13y agoHmm, I was going to list additional standard libraries that I use on a regular basis to "prove" the author wrong, but I could only come up with two (in addition to your list): csv & re. Still, the only thing I use with any frequency that is an outright replacement for standard library functionality is requests and beautifulsoup. Well, if you don't include ipython, which is an absolute necessity.
- jdost 13y agoI also like using argparse. Nice utility library to "power up" helpful scripts.
- vezzy-fnord 13y agoArgument parsing is an essential utility and part of the standard library in all major programming languages, though. Dating back to getopt becoming a standard in C (or earlier?) Or do you find Python's argument parsing to be especially notable for some reason?
- RyanMcGreal 13y agoFor a language whose motto is "There should be one - and preferably only one - obvious way to do it", Python has at least four ways to handle command line arguments out-of-the-box: * sys.argv * argparse * optparse * getopt There are, of course, additional third party modules (like opster) that also handle arguments.
- mattdeboard 13y agosys.argv is part of the interpreter. The other three are abstractions over it. optparse is deprecated (kept around for obvious backward-compat reasons) getopt is just a different API for people who feel more comfortable with C's getopt API and don't want to learn something else argparse is the CLI option parser for the future. tl;dr: There is one way to parse command line arguments: sys.argv. But there are a few abstractions of doing that available in the stdlib.
- Someone 13y agoIs getopt part of the C library? I think it only is POSIX, not C.
- falcolas 13y agoI can come up with quite a few of them. os sys logging os.path re subprocess datetime json pickle itertools urllib2 signal traceback socket It has a lot to do with my job - devops for remote clients. I can't rely on the ability to use 3rd party python libraries, and my stuff has to work reliably with few problematic corner cases. The standard library fulfills both of those cases pretty well. To refer back to the "old batteries" argument, the included batteries may be the old lead acid type, but they're dependable in a lot of cases where newer lithium ion batteries would rather catch fire.
- Daishiman 13y agoIf I may ask, what's wrong with datetime? I may not have encountered unusual cases, but for most uses the date + datetime + timedelta scheme seems to work pretty well.
- falcolas 13y agoI don't think anything is wrong with datetime - it's just a stdlib tool that I use on a regular basis. Sorry, wasn't listing just those I think have warts or those replaced by other tools, just libs that I use regularly.
- d23 13y agoMy only gripe with datetime and time are the organization of it. I can never remember whether it's datetime.datetime.now or datetime.now or time.timedelta or datetime.timedelta, and so on.
- falcolas 13y agoYeah, typing datetime.datetime for everything gets pretty old. I just remember that datetime is the package, datetime.datetime is the class, and datetime.datetime.now() is a @classmethod that returns instances of that class. I do kinda wish it was datetime.now() for the constructor instead.
- seanconaty 13y agoYou mentioned itertools twice. Accident or pun intended?
- mjolk 13y agoI agree with you that the title is baiting. His complaints are essentially: 1. The 'sys' and 'os' modules require too much typing and aren't 'beautiful' enough. 2. 'Requests' isn't stdlib. (because obviously) 3. Rargh time zones are annoying. (not python's fault that we, as people, split time into arbitrary 'zones') 4. I prefer a different testing module. And his solutions are: 1. To use a wrapper that requires a little less typing. 2. To complain about it. 3. To use a third party lib that 'solves' the issue because it gets updated more frequently. 4. To use a different testing module. I don't see how any of this means that Python's stdlib has 'dead batteries.' What a garbage article. On a side note, I feel this is a terrible idea: >The proposal introduces a provisional stage that allows packages to go into the standard library without enforcing the hard guarantees of backwards compatibility and API stability that previously made standard library inclusion undesirable. The standard lib should be made of things that are rock solid. You don't build a house on unreliable-but-so-fun-to-use materials, nor should Python mess with stability so that blog writers bitch less.
- norswap 13y agoI like the use of "dated". urllib is horrible and was never good to begin with.
- RyanMcGreal 13y agoI get a sense the author just wanted to complain, since he seems to agree with why most of his examples aren't in the stdlib. Sidenote: the json module lives in the stdlib now but started out as a third party module, simplejson. Not sure what that says vis-a-vis the author's fuzzy thesis.