Doug Hellmann
doughellmann.com · Personal blog · on HN since 2008
Doug Hellmann, a Python developer, writes Python Module of the Week, a series of tutorials on the standard library, plus performance notes.
What HN saysHN commenters often recommend PyMOTW and his book 'The Python Standard Library by Example' as the best way to learn the standard library.
44HN people shared it
20linked it in comments
28stories submitted
325story points
3 years agolast shared
2008people per year2026
Most-shared posts
- 1Python Module of the Week5 people · 11 points · first shared 2008 · discussion on HN
- 2PyMOTW: Python Module of the Week4 people · 7 points · first shared 2009 · 1 comments on HN
- 3The Performance Impact of Using dict() Instead of {} in CPython 2.73 people · 11 points · first shared 2013 · 1 comments on HN
- 4Virtualenvwrapper3 people · first shared 2010
- 5The Performance Impact of Using dict() Instead of {} in CPython 2.72 people · 53 points · first shared 2012 · 13 comments on HN
- 6The Performance Impact of Using dict() Instead of {} in CPython 2.72 people · 7 points · first shared 2012 · discussion on HN
- 7Python 2.6 abc - Abstract Base Classes2 people · 1 points · first shared 2009 · discussion on HN
- 8Python In-Memory Data Structures1 people · 52 points · first shared 2009 · 1 comments on HN
- 9Python Module of the Week1 people · 45 points · first shared 2012 · 5 comments on HN
- 10Python `select` module - well explained step by step1 people · 41 points · first shared 2010 · 6 comments on HN
- 11How I Review a PyCon Talk Proposal1 people · 29 points · first shared 2011 · discussion on HN
- 12Python profile, cProfile, and pstats – Explained step by step1 people · 28 points · first shared 2010 · 1 comments on HN
- 13Itertools - Iterator functions for efficient looping1 people · 20 points · first shared 2010 · 9 comments on HN
- 14Using Fuzzy Matching to Search by Sound with Python1 people · 4 points · first shared 2012 · discussion on HN
- 15Dependencies Between Python Standard Library Modules – Doug Hellmann1 people · 3 points · first shared 2019 · discussion on HN
What HN people wrote when they linked it
iliaznk · 2018-12-28
This is not really the kind of book you're looking for, I'm, afraid, but still it's the best one I've read on Python in general http://shop.oreilly.com/product/0636920032519.do
As a language reference you could use something like that https://gto76.github.io/python-cheatsheet/ or another good book https://doughellmann.com/blog/the-python-3-standard-library-by-example…
aslewofmice · 2012-05-01
I felt that way about some of the standard documentation but was relieved to find: http://www.doughellmann.com/PyMOTW/
I also highly recommend checking out Doug Hellman's book 'The Python Standard Library by Example'. He presents every (or almost every) standard library module with simple explanations and plenty of examples.
windexh8er · 2011-08-09
I'm surprised nobody has mentioned Doug Hellman's great resources. His book "The Python Standard Library by Example" is basically a print version of his PyMOTW project (http://www.doughellmann.com/PyMOTW/). While not an end to end "learn Python" the examples, at least in my case, have led me to ask quite a few questions that open other doors into Python that I haven't been exposed to.
I like what Zed has put out, but the books Lutz has out are great as well. Hetland's book is OK and Paul Barry's "Head First Python" is a great read if you're a true beginner to get your feet wet with a fun book. It's an easy read, but I would think that the transition to "Learning Python" would feel like a slight step backwards - however "Programming Python" by Lutz may be a better logical step (instead of going back through a lot of the basics).
mace · 2009-10-06
The Python standard has some pure Python modules may be worth looking at. Doug Hellmann's Python Module of the Week, http://www.doughellmann.com/PyMOTW/contents.html, is good place to start.
I'd recommend looking at code that interests you. It will make reading the code more interesting and perhaps more useful. Here are some popular projects arrange by interest:
Web framework: Django, Pylons
TCP/IP networking: the official Bittorrent client, Mercurial, Tornado
Database: SQLAlchemy, SQLObject
Past HN submissions are generally a good place to find interesting projects too: http://searchyc.com/submissions/python?sort=by_points
jnoller · 2008-10-09
I would definitely recommend sync'ing the python subversion tree and picking a few modules and reading through them. Doing so taught me some of the less obvious things within the language, and also taught me a lot about the various dunder (__foo__) methods for objects.
Additionally, I'd recommend reading through the PEP documents (http://python.org/dev/peps/) - there's a lot of great examples and rationales contained in those.
Finally, Doug hellmann has done an excellent job with his Python Module of the Week series (http://www.doughellmann.com/PyMOTW/) and a new project "The hazel tree" (http://www.thehazeltree.org/) is doing a great job at compiling the various examples, docs/etc together in one place.
wyldfire · 2024-01-23
A previous analysis of the same question (2.7, 2012): https://doughellmann.com/posts/the-performance-impact-of-using-dict-in…
mkhattab · 2013-03-16
> There's a performance penalty to using Python, too.
I agree, but if it wasn't for the fact that using dict() is six times slower than using literals then it wouldn't make much of a difference arguing code style [1].
> (By that logic, you should represent sets as {'element': 1} instead of set('element'), because calling the function "set" is slower than making a dictionary object from the special syntax.)
Which is why I guess there are now set literals in Python (just not for empty sets :).
--
[1]: http://doughellmann.com/2012/11/the-performance-impact-of-using-dict-i…
rplnt · 2012-11-14
If you don't have the time to read through just jump here: http://www.doughellmann.com/articles/misc/dict-performance/#conclusion…
sciurus · 2012-08-27
If you'd prefer the material in print, Doug has written The Python Standard Library by Example.
http://www.doughellmann.com/books/byexample/
d0mine · 2012-08-20
So that you could:
from java.util import Stack
Instead of:
from jnius import autoclass
Stack = autoclass('java.util.Stack')
http://www.doughellmann.com/PyMOTW/sys/imports.html#custom-importers
pmiller2 · 2012-08-20
Abstract base classes. See http://www.doughellmann.com/PyMOTW/abc/
eliben · 2012-08-03
Honestly, I don't see a reason to repeat what Doug Hellman did with Python Module Of The Week a while ago:
http://www.doughellmann.com/PyMOTW/py-modindex.html
His articles are comprehensive (were made into a book). For example, the one on logging is here:
http://www.doughellmann.com/PyMOTW/logging/index.html#module-logging
hoka · 2012-08-02
As someone learning python (on mostly windows, but I test on ubuntu now and then to see if it works well) my advice is to just learn the multiprocessing version as shown by hythloday.
I had a lot of problems with threads not exiting/joining properly, and even my multiprocessing code was goofy on windows. I used the "poison pill" method at http://www.doughellmann.com/PyMOTW/multiprocessing/communication.html#… and everything works on ubuntu.
I'm aware of the __main__ thing for windows, but I don't think that's my problem :-/
mas1n · 2012-05-01
Or you can install virtualenvwrapper (http://www.doughellmann.com/projects/virtualenvwrapper/) and after a little configuration...
$ mkvirtualenv env1
(env1)$ pip install somepackage
Creating self containing python projects has never been so easy!
easonchan42 · 2012-04-08
Doug hellmann's awesome Python Module of the Week series
(http://www.doughellmann.com/PyMOTW/)
alexis-d · 2012-04-03
I think you missed my point.
I agree that for trivial regex it's useless. For instance (directly taken from Python doc) in this case:
a = re.compile(r"""\d + # the integral part
\. # the decimal point
\d * # some fractional digits""", re.X)
b = re.compile(r"\d+\.\d*")
that's useless. But for more complex problems it may be useful (e.g. http://www.doughellmann.com/PyMOTW/re/ I know email matching regexes are not really complex or even a good example of use of regexes but that's the first example I found).
Another point is that even if I can read/write (that's the case) regexes other people may have to deal with my code and it's a well known fact that many people doesn't understand/like regex, so splitting them in small "chunks" may help them.
tmm1 · 2011-02-22
rbtrace is built on ruby's event hook api, which provides events when ruby and C extension methods are called, and when they return.
python offers a very similar event hook api: http://www.doughellmann.com/PyMOTW/sys/tracing.html
IgorPartola · 2010-10-24
I usually deploy it is nginx => Django FastCGI via flup. Make sure to use prefork instead of threaded method. On top of that I run each Django project inside individual virtualenv's [1], where virtualenvwrapper [2] simplifies the process. Since all my servers are Debian-based, I use my own creation called flint [3] to automatically start/stop the FastCGI processes on boot/shutdown. For deploying code I use fabric [4] and then simply $ flint restart_all or $ flint restart myproject to reload the code.
[1] virtualenv - http://virtualenv.openplans.org/
[2] virtualenvwrapper - http://www.doughellmann.com/projects/virtualenvwrapper/
[3] flint - http://igorpartola.com/projects/flint
[4] fabric - http://docs.fabfile.org/0.9.2/
nailer · 2010-09-21
Stuff that belongs to the OS (but runnable by all users) is in /usr/bin. That's FHS.
Stuff that's yours is wherever dir you specified when you ran:
export WORKON_HOME=$HOME/.virtualenvs
Seriously. Use virtualenv (and virtualenvwrapper).
http://www.doughellmann.com/projects/virtualenvwrapper/
gte910h · 2010-06-26
I'm a guy from a C/C++ background who did linux kernel development, and picked up python along the way and used it to do desktop tools. I used python (without knowing any of it) to write a disassembler for a project I was doing in 2003 on a non-x86 processor. It took me 5 days to learn the language enough to do so and to write the entire tool, at which point I "got it".
First off, Java isn't a toy language. You've characterized it improperly. Java is a bureaucratic language. You have to cross your t's dot your i's, fill out your requests in triplicate at the FactoryFactoryFactory to get the objectOfYourDesire. Why is this so?
This comes back to how C++ works on projects, especially large projects and midsize projects with a couple mediocre programmers thrown in (because, in commercial software development, you rarely get control of your team). C++ does not work well for large team development unless 1> You have very capable people 2> and you can fire everyone who steps outside the "defined okay subset" of C++ you use on the project. The language is too big, certain parts make it too uncertain, etc, for people to just willy nilly use all the language features. So Java, is basically Sun's "redoing" of C++ where they took its wild west nature, and made a BureauDisney version where you can't do a dozen things that happens in C++ all the time when good programmers go off the reservation or bad programmers enter the equation at all.
C++ has uses, but it's the sulfuric acid of…