1) When using a class method, it would be nice if the calling class
would be added as the 1st argument of the method.
First let me explain the nomenclature. A class method is a method
invoked through the class instead of the method. I.e.
Invoking foo.bar() is invoking a class method. You could invoke
the same method as a instance method, foo().bar(), however, it
would result in a 'TypeError: arg cound mismatch' since the
instance itself is automatically prepended to the argument list.
What I propose is to do the same when you invoke the method as a
class method, and prepend the class to the method. This would
Invoking foo.bar() would result in <type 'class'>, invoking
foo().bar() would result in <type 'instance'>. It is up to the
programmer to correctly code, invoke and identify class method vs.
instance methods (as with a lot of other things in python).
The benefit would be that you can define a class method in a base
class, and still have access to the invoking class. i.e.
new_instance = self()
Invoking bar.new() would return an instance of bar. The current
work-around is to invoke the class method as bar.new(bar).
2) It would be nice to have a special operator to implement the
'super' functionality. This functionality allows you to start
searching for a method starting at the base classes, not the
current class. The current workaround is to define a function to
delete the method from the current class (if it's there), retrieve
it using the normal method, and replacing the method in the current
class. This allows you to write:
new_instance = super(self, 'new')(self)
What I would like to see is some special operator that does this
for you, e.g. using a carrot:
new_instance = self^new()
3) It would be nice to be able to retrieve the name of a class. The
attribute exists, but is empty. I.e. bar.__name__ returns None.
Also, the address operator Guido was talking about would come in
very handy, since you would be able to define something like this
(given that '&' is the address operator):
try: return '<class ' + self.__name__ + 'at ' + `&self`
return '<instance ' + self.__class__.__name__ + 'at ' + `&self`
This brings up another point, and that is that __repr__ currently
doesn't work for classes, it would be nice if it did.
Suggestions and comments are welcome.
-- Jaap Vermeulen +--------------------------+ | Sequent Computer Systems | Internet : firstname.lastname@example.org | Beaverton, Oregon | Uucp : ...uunet!sequent!jaap +--------------------------+