total idiot question: +=, .=, etc...

Bernhard Herzog herzog at online.de
Tue Jun 29 06:49:33 EDT 1999


behrends at cse.msu.edu (Reimer Behrends) writes:

> For instance, I noticed that I much preferred the way Ruby denotes
> attributes, even though it uses a superficially similar approach (Ruby
> prefixes attributes with an "@" symbol rather than with "self."). So,
> for instance, instead of
> 
> 	self.last = self.lines[-1]
> 	self.lines = self.lines[:-1]
> 
> we have something like:
> 
> 	@last = @lines[-1]
> 	@lines = @lines[:-1]
> 

I think a better solution that better fits the python syntax is to
simply omit the self but not the dot:

	.last = .lines[-1]
 	.lines = .lines[:-1]

That is, if one really wanted to have a shorthand for instance variables
in methods.


-- 
Bernhard Herzog	  | Sketch, a python based drawing program
herzog at online.de  | http://www.online.de/home/sketch/




More information about the Python-list mailing list