python newbie

Paul Rubin http
Sun Nov 4 21:05:35 CET 2007


Bruno Desthuilliers <bdesth.quelquechose at free.quelquepart.fr> writes:
> >   from random import random
> >   x = random()
> >   y = random.choice((1,2,3))   # oops
> 
> from random import random, choice
> 
> x = random()
> y = choice((1, 2, 3))

Really, a lot of these modules exist primarily to export a single
class or function, but have other classes or functions of secondary
interest.  I'd like to be able to get to the primary function without
needing to use a qualifier, and be able to get to the secondary ones
by using a qualifier instead of having to import explicitly and
clutter up the importing module's name space like that.  It just seems
natural.



More information about the Python-list mailing list