Super() function

Alan Harris-Reid aharrisreid at googlemail.com
Sat Mar 27 11:08:09 EDT 2010


³p wrote:
> Hi:
>> On 25 March 2010 11:17, Alan Harris-Reid <aharrisreid at googlemail.com 
> <mailto:aharrisreid at googlemail.com>> wrote:
>> Hi,
>> Using Python 3.1, I sometimes use the super() function to call the
> equivalent method from a parent class, for example
>> def mymethod(self):
> super().mymethod()
> some more code...
>> Is there any way of writing the code so that the super() call is
> generic and automatically recognises the name of the current
> method (ie. something like super().thismethod()) or do I always
> have to repeat the method name after super()?
>> TIA,
> Alan
> -- 
> http://mail.python.org/mailman/listinfo/python-list
>>>>> I think, the super() method is designed to delegate any method call 
> to one of the class in its mro list, and the super() function its self 
> return a 'super' object, so it is better to write what method you want 
> to delegate, maybe it's not the current method. 
>> -- 
> Best wishes from Ray ...
Thanks Ray - I'll stick to repeating the method name.
Regards,
Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100327/f8caf4f5/attachment-0001.html>


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /