Style question: Importing modules from packages - 'from' vs 'as'

Ethan Furman ethan at stoneleaf.us
Thu Dec 4 13:02:54 EST 2014


On 12/03/2014 03:02 AM, Chris Angelico wrote:
> 
> Throughout the code, I want to refer to "path.split()",
> "path.isfile()", etc, without the "os." in front of them. I could do
> either of these:
> 
> import os.path as path
> from os import path
> 
> Which one would you recommend? Does it depend on context?

I recommend the one with less typing.  ;)

--
~Ethan~

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20141204/4f0237f0/attachment.sig>


More information about the Python-list mailing list