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

Tim Delaney timothy.c.delaney at gmail.com
Wed Dec 3 06:15:19 EST 2014


On 3 December 2014 at 22:02, Chris Angelico <rosuav at gmail.com> wrote:

>
> import os.path as path
> from os import path
>

Bah - deleted the list and sent directly to Chris ... time to go to bed.

The advantage of the former is that if you want to use a different name,
it's a smaller change. But the disadvantage of the former is that if you
*don't* want to rename, it violates DRY (don't repeat yourself).

The difference is so marginal that I'd leave it to personal preference, and
wouldn't pull someone up for either in a code review.

Tim Delaney
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141203/bc31568e/attachment.html>


More information about the Python-list mailing list