A better self

David LeBlanc whisper at oz.net
Tue Jul 9 18:10:59 EDT 2002


I notice that in every discussion of self, there's always a '.' in there.
So, why not make a leading '.' mean self? AFAIK, it's otherwise currently
illegal. The only drawback that I can think of is that it's less visible as
a first argument for class defs.

class foo():
	def __init__(., me, me2, me3)
		.a = me
		.b = me2
		.c = me3
	def fee(.)
		print .a, .b, .c
	def bar(.)
		.fee()

What I like about it is that it's resonant with the use of '.' to denote
members/components of modules (i.e: sys.path) and suggests that the
identifier is a member of the local "capsule" (or class scope if you
prefer). I see it as answering the needs of both camps: it's easy to typy,
unobtrusive and yet supports the "belt and suspenders" crowd who are not
comfortable with an implied self.

Before you all react (programmers can be SO conservative), please think
about it!

David LeBlanc
Seattle, WA USA






More information about the Python-list mailing list