tjreedy at udel.edu
Sat Nov 1 03:26:22 CET 2003
"John J. Lee" <jjl at pobox.com> wrote in message
news:873cd9m6mo.fsf at pobox.com...
> "Sean Cody" <sean at -[NOSPAMPLEASE]-tfh.ca> writes:
> > I use a lot of member variables. Is there a way to not have
> > to reference members by self.member.
1. call the parameter s instead of self; then it is s.member.
But best not to post code with that, lest you upset some readers ;-).
> > Back in the day in pascal you could do stuff like
> > "with self begin do_stuff(member_variable); end;"
> > which was extremely useful for large 'records.'
There have been proposals something like that, but they do not seem to
fit Python too well.
> Well, obviously, there's:
> mv = self.member_variable
In case you think this a hack, it is not. Copying things into the
local variable space (from builtins, globals, attributes) is a fairly
common idiom. When a value is used repeatedly (like in a loop), the
copying is paid for by faster repeated access.
Terry J. Reedy
More information about the Python-list