Two minor syntactic proposals
Michael Haggerty
mhagger at alum.mit.edu
Thu Jul 12 14:42:10 EDT 2001
Greg Ewing <see at my.signature> writes:
> I like this idea too! The way I'd describe it is as allowing a
> general l-value (i.e. anything that can appear on the lhs of an
> assignment) in place of the current identifier-being-bound in def,
> class and import statements.
>
> (On the downside -- I like the def self.foo() idea too, and this is
> in direct conflict with it! Sigh, can't have everything, I suppose,
> and I think I'd rather have this than def self.foo() if it came down
> to a choice.)
Bengt Richter <bokr at accessone.com> writes:
> I think I prefer just an easier way to type "self."
> How about just the dot? I.e., ".x" means "self.x"
What about combining the ideas: within a class definition or instance
method definition, ".x" means "self.x". Thus:
class C:
def .x(arg):
# defines instance method; "self" would be a magic implicit
# first parameter (requires special treatment for word "self".
def C.x(arg):
# defines class (static) method
def f(self, arg):
# Defines instance method (for backwards compatibility)
Michael
--
Michael Haggerty
mhagger at alum.mit.edu
More information about the Python-list
mailing list