Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15622
| References | <4ebe5ee6$0$25872$426a74cc@news.free.fr> |
|---|---|
| Date | 2011-11-12 12:29 +0000 |
| Subject | Re: Use and usefulness of the as syntax |
| From | Arnaud Delobelle <arnodel@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2669.1321100968.27778.python-list@python.org> (permalink) |
On 12 November 2011 11:56, candide <candide@free.invalid> wrote: > First, could you confirm the following syntax > > import foo as f > > equivalent to > > import foo > f = foo > > > > Now, I was wondering about the usefulness in everyday programming of the as > syntax within an import statement. Here are some instances retrieved from > real code of such a syntax > > import numpy as np > > import math as _math > > import pickle as pickle > > > -- In the first case, the syntax is motivated by brevity need, isn't it ? Correct! > -- The second case seems to be rather widespread and causes math attribute > to be private but I don't figure out why this matters. This way math doesn't get bound in the global namespace when doing "from module import *" > -- In the last case, I can see no point Neither can I > So what is the pragmatics of the as syntax ? It can also help when you want to import two different modules with the same name. -- Arnaud
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Use and usefulness of the as syntax candide <candide@free.invalid> - 2011-11-12 12:56 +0100
Re: Use and usefulness of the as syntax Chris Angelico <rosuav@gmail.com> - 2011-11-12 23:27 +1100
Re: Use and usefulness of the as syntax Arnaud Delobelle <arnodel@gmail.com> - 2011-11-12 12:29 +0000
Re: Use and usefulness of the as syntax candide <candide@free.invalid> - 2011-11-17 16:48 +0100
Re: Use and usefulness of the as syntax alex23 <wuwei23@gmail.com> - 2011-11-17 18:38 -0800
Re: Use and usefulness of the as syntax Tim Chase <python.list@tim.thechases.com> - 2011-11-12 06:43 -0600
Re: Use and usefulness of the as syntax Rafael Durán Castañeda <rafadurancastaneda@gmail.com> - 2011-11-12 13:48 +0100
Re: Use and usefulness of the as syntax 0xfn <oleg.rimko@gmail.com> - 2011-11-13 00:55 -0800
Re: Use and usefulness of the as syntax Terry Reedy <tjreedy@udel.edu> - 2011-11-13 17:16 -0500
Re: Use and usefulness of the as syntax Tim Wintle <tim.wintle@teamrubber.com> - 2011-11-12 13:03 +0000
Re: Use and usefulness of the as syntax Mel Wilson <mwilson@the-wire.com> - 2011-11-12 08:59 -0500
Re: Use and usefulness of the as syntax candide <candide@free.invalid> - 2011-11-17 16:48 +0100
csiph-web