total idiot question: +=, .=, etc...
Tim Peters
tim_one at email.msn.com
Tue Jun 29 11:56:56 EDT 1999
>>> class A(B):
>>> def __init__(self, x, y, z):
>>> B.__init__(self, x, y, z)
[Greg Ewing]
> I could live with having to explicitly name the
> superclass, provided something checked that the
> class I named was actually a direct base class
> of the one where the method is defined. That
> way things would be less likely to break
> mysteriously when I rearrange the class
> hierarchy.
[Guido]
> Oh, but that check *is* being made! (In fact this is the same check
> that prevents "class methods" from working ;-)
Nope, that's a different check. If C derives from B derives from A, this
check allows either C.__init__ or B.__init__ to be called from A.__init__
with an instance of A. Greg wants B.__init__ to be OK here, but not
C.__init__ (C is not a direct base class of the one (A) where the method
(A.__init__) is defined). IOW, he wants a way to restrict __init__ calls to
immediate bases of the class from which the __init__ is invoked, to e.g.
prevent level-skipping under class rearrangement.
I posted some ugly code to address that, but think it's really a job for a
text editor and a pair of eyeballs <wink>.
although-something-to-be-said-for-automating-the-eyeballs-ly y'rs - tim
More information about the Python-list
mailing list