[Tutor] subclass not inheriting attributes?

Walter Prins wprins at gmail.com
Tue Jan 4 02:12:20 CET 2011


On 4 January 2011 00:47, Alex Hall <mehgcap at gmail.com> wrote:

> class parent(object):
>  def __init__(self, l=None):
>  if l is None: l=[]
>

Missing "self". Perhaps you meant:

class parent(object):
 def __init__(self, l=None):
   if l is None: self.l=[]
   else: self.l=l


Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110104/a1c27019/attachment-0001.html>


More information about the Tutor mailing list