Python Library Question

Jeff Shannon jeff at
Thu Aug 23 18:56:47 CEST 2001

Markus Schaber wrote:

> Hi,
> Jeff Shannon <jeff at> schrub:
> >>>> import math
> >>>> x = 2
> >>>> y = math.exp(2)
> >>>> y
> > 7.3890560989306504
> Another way would be:
> >>> from math import exp
> >>> exp(2)
> 7.38905609893
> >>>
> As you know, there's always _one_ obvious way to do it, but this only
> way may have just lots of lanes :-)

True, though I think the phrase was "at least one, and preferably only one",
but that's splitting hairs.  :)

Personally, I greatly prefer the original, explicit form--it's much easier
to read and keep track of, especially when trying to read a longish script
written by someone else (and as a side benefit, is more amenable to reload()
if that is ever necessary).  So I would try to encourage people, especially
newbies, to use that form rather than "from x import y", and strongly
discourage "from x import *" of course.  :)  Of course this is personal
opinion, and there are specific cases where these guidelines do not apply,
but then, there's an exception to every rule...

Jeff Shannon
Credit International

More information about the Python-list mailing list