Movatterモバイル変換


[0]ホーム

URL:


Deprecate self

s713221 at student.gu.edu.aus713221 at student.gu.edu.au
Thu Apr 19 06:36:48 EDT 2001


Dave LeBlanc wrote:> I was going to mention super, but given the multiple inheritance> nature of Python, it wouldn't work.If you want super functionality, a poster a year or so ago, submittedthis little hack for a situation where he wanted to use a derived classwith multiple base classes, but without having to retype dozens of linesof code.class friendly:def __init__(self):print "Hello"class friendlier(friendly):def __super(self):return friendlydef __init__(self, name):self.__super().__init__(self)print nameAs long as you've only got single inheritance, or are only interested inthe first class, you can automate it as follows:class friendlier(friendly):def __super(self):return self.__class__.__bases__[0]Useful in some situations,Joal Heagney/AncientHart


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp