Shortcut operators (was Re: [MATRIX-SIG] random number generat or?)

Perry A. Stoll pas@xis.xerox.com
Wed, 29 Oct 1997 13:43:00 PST


On 29 Oct , Zane C. Motteler wrote:
> Just a quick response to Perry Stool's example,
> 
> self.obj_list[self.obj_offset].count = self.obj_list[self.obj_offst].count + 1
> 
> It is only necessary to type something like self.obj_list[self.obj_offset].count
> once. Don't we all have a mouse and "copy/paste" capability?

Well, of course we do (that's how I did it for that example!) but... my
feeling is that you're doomed once you start down the dark path of
cut/paste while coding... ;)

Actually, I was just trying to get some complex expression that
wouldn't be easily deconstructed at first glance. The point was to
ask : which says "add one to this thing" in the most clear way?

> There are
> ways to obviate all that typing. Also, it is possible in Python to alias
> complicated expressions and possibly give them more easily readable
> names, e. g.
> 
> current_object = self.obj_list[self.obj_offset]

I believe that was the second alternative in my example.

Again, if all I want to do is "add one" to something, does aliasing the
object express that more clearly than foo += 1? 


-Perry



_______________
MATRIX-SIG  - SIG on Matrix Math for Python

send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________