import syntax

Tim Chase python.list at tim.thechases.com
Mon Jul 29 22:20:51 CEST 2013


On 2013-07-29 16:09, Dave Angel wrote:
> On 07/29/2013 03:48 PM, Devyn Collier Johnson wrote:
> > The PEP8 recommends importing like this:
> >
> > import os
> > import re
> >
> > not like this:
> >
> > import os, re
>
> I got a bit further, and if I'm only using a couple of functions
> from the import, I'll list them in the comment.

If I just plan to use a small subset, I tend to reach for the

  from sys import stdout, stderr, exit

sort of syntax.  I find it makes my code read a bit more cleanly than
having to type "sys.stderr.write(...)" everywhere but is still pretty
readable.

-tkc





More information about the Python-list mailing list