Dave Angel wrote:
> Michael Torrie <[email protected]> Wrote in message:
>> You can do it two ways:
>> Refer to it as random.shuffle()
>>
>> or
>>
>> from random import shuffle
>>
>> I tend to use the first method (random.shuffle). That way it prevents
>> my local namespace from getting polluted with random symbols imported
>> from modules.
>
> Or a third way:
>
> import random
> shuffle = random.shuffle
Our three weapons are:
(1) fully qualified names:
import random
random.shuffle
(2) unqualified local imports:
from random import shuffle
(3) local name binding:
import random
shuffle = random.shuffle
(4) messing about under the hood:
shuffle = __import__('random', fromlist=['shuffle']).shuffle
(5) and a fanatical devotion to the Pope.
A serious question -- what is the point of the fromlist argument to
__import__? It doesn't appear to actually do anything.
https://docs.python.org/3/library/functions.html#__import__
--
Steven
--
https://mail.python.org/mailman/listinfo/python-list