Another reason assignment expressions would be nice (?)

alan at littleford.net alan at littleford.net
Sat Jul 10 23:12:54 EDT 1999


On Sat, 10 Jul 1999 23:50:42 -0400, "Tim Peters"
<tim_one at email.msn.com> wrote:

........
>How about
>
>    a = foo()
>    a.setAttr('i', 'self.SomeFunction()')
>    a.setTemplate("'A test line %d' % self.i")
>    a.setTemplate("'Same value as above %d' % self.i")
>
>?  Then (a) the code is easier to write; and, (b) when it all falls apart
>you can at least find your mutations in an editor via searching for
>"setAttr", or even turn on a debug flag causing setAttr to log what it's
>doing.
>
>different-operations-different-methods-ly y'rs  - tim
>

I'd thought along this line -- I'd even though about implementing a
stack within foo and then you could push, pop+push and pop args to and
fro -- this would do away with having to declare stuff (which the
setAttr() is really still doing) but would lead to the usual stack
management problems (as well as being hellish to understand, as you
intimated). Still and all, having i = 3 return 3 would be the nicest
for this app ..

Tnx
Alanl




More information about the Python-list mailing list