On Fri, Jun 12, 2009 at 8:37 AM, Lie Ryan<lie.1...@gmail.com> wrote:
>>>> class Normal(object):
> ...     def __new__(cls, arg):
> ...         if arg:
> ...             return Special(arg)
> ...         else:
> ...             ret = super(Normal, cls).__new__(cls)
> ...             ret.__init__(arg)
> ...             return ret

I think the else case should be
  ret = super(Normal, cls).__new__(cls, arg)
  return ret

i.e. pass the same args to super.__new__() and don't explicitly call __init__().

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to