[Cheetahtemplate-discuss] Python super (off topic; was: Re: [Cheetahtemplate-discuss] #set vs. #dat
Brought to you by:
rtyler,
tavis_rudd
From: Chuck E. <Chu...@ya...> - 2001-09-10 23:26:00
|
At 09:34 AM 8/24/2001 -0700, Mike Orr wrote: >Java vs Python. Java has all these extra rules and constructs for inner >classes (=classes inside classes), accessing an overridden method >( super.METHOD() ), a special syntax in the init method to call the >superclass' init method ( super() ), and it even has a "new" operator >for creating an instance. Python gets along beautifully without any of >that crap. Want an instance? Call the class. Want to call an >overridden method? Just do it. Want to create an inner class? Just do >it. Want to rename your class? No need to rename __init__ . Wait, if you think not renaming __init__ is an advantage when renaming a class (and I agree), you must be really upset (like I am) that you have to browse every method of every subclass and rename all the invocations of super: from A import A class B(A): def foo(self): A.foo() self.bar() If A is renamed, then we might have to update the source of every subclass of A. We at least have to check. It would be easier if we could just invoke super: from A import A class B(A): def foo(self): super.foo() self.bar() You might still need to update the import and class line, but at least you don't have to wade through all the methods. "super" would be a nice addition to Python because it's common and the alternative is high maintenance. -Chuck |