Initializing a set from a list

Robert Kern robert.kern at gmail.com
Wed Jun 21 20:43:28 CEST 2006


Xiaolei wrote:
> Sybren Stuvel wrote:
> 
>>Xiaolei enlightened us with:
>>
>>>from pylab import *
>>
>>You'd better not do that. Just use "import pylab".
>>
>>>If I remove the first line, I correctly get:
>>>
>>>[1, 2, 3, 3]
>>><type 'set'>
>>>set([1, 2, 3])
>>
>>Pylab shadows the built-in set name, which is one of the reasons you
>>should generally use "import XXX" instead of "from XXX import *".
> 
> Ahh.  Understood.  Thank you very much.

It should be noted that recent versions of matplotlib's pylab module have
changed that function to setp() in order to avoid this problem.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the Python-list mailing list