Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!txtfeed1.tudelft.nl!tudelft.nl!txtfeed2.tudelft.nl!amsnews11.chello.com!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.018 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'situation.': 0.05; 'suppose': 0.05; 'forcing': 0.07; 'foo': 0.09; 'syntax': 0.15; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:syntax': 0.16; 'wrote:': 0.18; 'received:209.85.210.174': 0.18; 'received:mail-iy0-f174.google.com': 0.18; 'header:In-Reply- To:1': 0.23; 'variable': 0.24; 'loaded': 0.25; 'separate': 0.28; 'sat,': 0.28; 'import': 0.28; 'around.': 0.28; 'bound': 0.28; 'convention': 0.28; 'importing': 0.28; 'message- id:@mail.gmail.com': 0.29; 'closer': 0.30; 'equivalent': 0.30; 'nov': 0.31; 'pm,': 0.31; 'to:addr:python-list': 0.32; 'done': 0.33; 'something': 0.36; 'but': 0.37; 'received:google.com': 0.38; 'received:209.85': 0.38; 'option': 0.38; "it's": 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'received:209': 0.40; '2011': 0.62; 'power,': 0.67; 'yourself': 0.68; '10:56': 0.84; 'candide': 0.84; 'different.': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=fSGBipvljr8rXRa3rMgooSXuK8jBnhQ1xiEjWSi8HW4=; b=ka+JLi6zIgscDVdcmh0QaaK3373uhIfay96GjtCsOLbYnS72OcooS0cxc4XZSkHY3I it201nsjaku9uWNY1xC06Z7DU5z3OoUBHvG8jgnjoRXdEUo5jPrrJ81OWY/xTU4LS/lw QQqBspKC1YiSlDcdKVvw93mZVye1df7lItN6A= MIME-Version: 1.0 In-Reply-To: <4ebe5ee6$0$25872$426a74cc@news.free.fr> References: <4ebe5ee6$0$25872$426a74cc@news.free.fr> Date: Sat, 12 Nov 2011 23:27:56 +1100 Subject: Re: Use and usefulness of the as syntax From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1321100879 news.xs4all.nl 6903 [2001:888:2000:d::a6]:57921 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:15621 On Sat, Nov 12, 2011 at 10:56 PM, candide wrote: > import foo as f > > equivalent to > > import foo > f = foo > Not quite, it's closer to: import foo f = foo del foo without the fiddling around. What the 'import... as' syntax gives is a way to separate the thing loaded from the name bound to. Suppose importing were done thus: foo = import("foo.py") Then you'd have a standard convention of always importing into a variable of the same name (loose terminology, but you know what I mean), with the option of importing as something completely different. The "import... as" syntax gives the same power, without forcing you to repeat yourself in the common situation. ChrisA