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

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

behrends at (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  |

More information about the Python-list mailing list