data strucutures in python

Dan Schmidt dfan at harmonixmusic.com
Wed Sep 20 09:34:18 EDT 2000


"Matthew Banham" <matb at photond.com> would like the following
functionality:

| For example say I have:-
| 
|   p = 'lambda', ChangeLambdaFunc
| 
| and I type the line:-
| 
|   lambda = 10
| 
| then the above line gets implemented as:-
| 
|   ChangeLambdaFunc(10)

I hate to inflict any sort of Perl advocacy on this newsgroup, but
it handles this sort of thing very well with the 'tie' mechanism.
So if you are familiar with Perl and it's a small enough program
that rewriting it in another language isn't that bad, you might want
to consider that.

I think that to get exactly the effect you are looking for in Python,
you're going to have to do some real under the hood hackery with the
global dict or something, or do some indirection through an explicit
function call, e.g.:

  lambda.set(10)

Or you could just wait a couple hours and Michael Hudson will probably
post a bytecodehack that solves your problem in a dozen lines.

-- 
                 Dan Schmidt | http://www.dfan.org
Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html



More information about the Python-list mailing list