Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #81851

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <timothy.c.delaney@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; "subject:' ": 0.07; 'os.path': 0.09; 'subject:modules': 0.09; 'violates': 0.09; 'subject:question': 0.10; "wouldn't": 0.14; 'wrote:': 0.18; 'import': 0.22; 'email addr:gmail.com&gt;': 0.22; 'to:name:python- list@python.org': 0.22; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'leave': 0.29; 'tim': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; "i'd": 0.34; 'subject:from': 0.34; 'december': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'list': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'personal': 0.63; 'different': 0.65; 'repeat': 0.74; 'dry': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=7dFgIPcCdbxteL6Ck9SHv+gONfAP8LRbYZrLjiGfrHY=; b=WjWre6hqtMcj9lN8uvGcVs3nOJTUu5h+UTWonV+xRbMk2WwnWnkYX2fTX2PF3skkHz XsQosFDkDZmyC+ds6FsjbG6jcK3BGgnseLY/1LqVHhTVrnGr5XpWQ/RL7+Jm6JZ+nYSI n3RQxbjVa5LDyfgqo5tyAColGC9VODFe0O1jCDXJCpc/+oQJ1eljIhAO/MbYqCdN96vu jnT21HgYzmzyGpYQ43IamMIuQvJF4hDP8MEsJoX+1wgrVWuRpCf3d6N0fZ/W7xBXLJjB U7F6pciJRQwFnxE5OhBMS+BovK9TECdRXhO+O5kpwnI7NMPD1myjwFLj85kWceO5guj/ OtKQ==
MIME-Version 1.0
X-Received by 10.180.82.98 with SMTP id h2mr12763846wiy.7.1417605319118; Wed, 03 Dec 2014 03:15:19 -0800 (PST)
In-Reply-To <CAPTjJmo1-QCgcbsjKNgH3oN-nm5qjB5GrvCiC6Qc9p+S8cNjpg@mail.gmail.com>
References <CAPTjJmo1-QCgcbsjKNgH3oN-nm5qjB5GrvCiC6Qc9p+S8cNjpg@mail.gmail.com>
Date Wed, 3 Dec 2014 22:15:19 +1100
Subject Re: Style question: Importing modules from packages - 'from' vs 'as'
From Tim Delaney <timothy.c.delaney@gmail.com>
To "python-list@python.org" <python-list@python.org>
Content-Type multipart/alternative; boundary=f46d044283ec7a586b05094df5d5
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16526.1417605326.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1417605326 news.xs4all.nl 2913 [2001:888:2000:d::a6]:50847
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:81851

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On 3 December 2014 at 22:02, Chris Angelico <rosuav@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Style question: Importing modules from packages - 'from' vs 'as' Tim Delaney <timothy.c.delaney@gmail.com> - 2014-12-03 22:15 +1100

csiph-web