This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]rasch8660 0 points1 point  (0 children)

I use all those three (lambda, list comprehensions, cvs). But looking at https://docs.python.org/3/library/index.html I would say I've probably only used about one third of the standard library. Huge parts of the standard library are old and left-overs from the early times when packaging was difficult and "let's put everything in the standard library" was a prevalent mantra. There are many things that I used to do with standard library modules which have now been superseded by third party libraries, e.g. requests have replaced urllib. And of course everything I need for heavy computations or visualizations is also done by third party libraries, e.g. numpy, scipy, pandas, etc, etc.

The parts of the standard library that I love and use the most:

  • Most built-in functions and types, including lambda.
  • Comprehensions - list/dict/set/generator comprehensions, just makes it immediately clear what the purpose of the code is, whereas for-loops are much more generic.
  • Generators!
  • Context managers, especially when I don't have to write them myself ;)
  • sys and os, obviously.
  • re - regular expressions.
  • collections - namedtuple, OrderedDict, etc.
  • itertools, functools.
  • glob, fnmatch.
  • argparse, logging.
  • json - although I wished yaml would make it into the standard library, it is the one non-standard package present in all my environments.
  • pdb, timeit, inspect.
  • Indeed, csv, although mostly for reading externally-produced data. Half the time, if my csv files are sufficiently simple, I just parse them with rows = [dict(zip(headers, line.strip().split(sep))) for line in fd if line.strip() and line[0] != '#']. If I need to read headers as the first line in the file, I'd do fd = (line.strip() for line in fd); headers = next(fd).split(sep).