Christoph Zwerschke wrote:
> The problem arises when you inherit directly from tuple since it is 
> immutable. Because of that, the argument is only used in the __new__ 
> method. You can try it out like that:
> 
> class MyTuple(tuple):
>      def __init__(self, sequence=None):
>          super(MyTuple, self).__init__()
> 
> print MyTuple((1, 2, 3))
> 
> If you do it like that, everything works fine, even though the sequence 
> argument is not passed.
> 
> If you remove the parameter from the __init__ definition, you will get a 
> TypeError (that was the mistake in my first patch that I corrected). And 
> if you pass it to __init__, you will get a deprecation warning in Py 2.6 
> since it is passed on to object who doesn't want it.
> 
> This is one of the rare situations where Python code really needs a 
> small comment, so I have added one now...

Wow, I can't believe they implemented it as magically as that.

Paul


_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[email protected]

Reply via email to