self
holger krekel
pyth at devel.trillke.net
Wed Jun 5 12:30:55 EDT 2002
Steve Holden wrote:
> "Vojin Jovanovic" <vjovanov at stevens-tech.edu> wrote ...
> [...]
> >
> > > Well, good luck with your project -- and don't spring any more
> > > requirements on us, it's getting harder each time to solve your problem.
> >
> > Sorry, but it is not that my problem is hard. It is that the concept of
> > having
> > to reference instance variables always through self. is making it hard and
> > inconvenient which was my point in my original post.
> > My opinion is that those points explained in FAQ are irrelevant. The only
> > one relevant is .....
> >
> [...]
>
> Could you maybe use self.__dict__ as a namespace argument to the eval()?
no his questions go deeper :-)
the problem is that the values in the dict have to be 'evaluated' if accessed.
For every name in such a value you need to evaluate its value again.
IOW it's recursive. The obvious solution is to intercept the namevalue-lookups
during evaluation of an equation. But this doesn't work for exec/eval:
They ignore the interception points.
IOW you cannot successfully wrap or inherit a dictionary type and pass it
to exec/eval :-(
The next best solution IMO is to preprend a namescope like 'self.'
to every name in an expression. But you may have to parse the expression to
do this. Maybe fixing exec/eval behaviour is a better idea?
regards,
holger
More information about the Python-list
mailing list