promoting [] by superclass?

Jim Newton jimka at rdrop.com
Tue Jun 8 13:38:28 EDT 2004


this is interesting.  I though that if you passed
an argument to your class factory function, it would call
the __init__ with that argument.

class x1(list):
   def __init__(y):
      pass

class x2(list):
   pass

what does x1([]) do and what does x2([]) do?

-jim

Robert Brewer wrote:
> Jim Newton wrote:
> 
>>class Pair(list):
>>   ...
>>
>>how can i "cast",  "promote" [] to class Pair?
> 
> 
>>>>class Pair(list): pass
> 
> ... 
> 
>>>>p = Pair([])
>>>>p
> 
> []
> 
>>>>type(p)
> 
> <class '__main__.Pair'>
> 
> Or was there some other behavior you had in mind?
> 
> 
> Robert Brewer
> MIS
> Amor Ministries
> fumanchu at amor.org
> 




More information about the Python-list mailing list