self

Delaney, Timothy tdelaney at avaya.com
Wed Jun 5 20:03:45 EDT 2002


> From: Vojin Jovanovic [mailto:vjovanov at stevens-tech.edu]
> 
> 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.

Actually, I think it's more that the problem is not specified correctly.

How would you do this in C? You haven't got any member variables there to do
it with.

How would you do it in C++? You can't execute arbitrary code.

How would you do it in Java? You can't execute arbitrary code.

You are trying to take advantage of a feature in Python (extreme dynamism)
and are then bemoaning that it doesn't work exactly as you would like?

What has happened is that you are no longer concentrating on the problem,
but on how to work around Python to make it work the way you think it should
work for this one problem domain.

The standard way of dealing with this is to create a parse tree for the
expressions and evaluate them, storing the actual values separately.

I think that in this case, the standard method is also the correct one.

Tim Delaney





More information about the Python-list mailing list