use strings to call functions

Klaus Neuner klausneuner72 at googlemail.com
Tue Feb 9 04:04:20 EST 2010


> go to hell ;-), it is part of the language, it seems to match the
> aforementioned question.

Thats right. In fact, your code is the precise analogy of my Prolog
example in Python. Obviously, eval() and call() are both inherently
dangerous. They should never be used in programs that are used in
programs that get input from people other than the author. Yet, my
program is supposed to parse files that I have created myself and that
are on my laptop. It is not supposed to interact with anybody else
than me.

On the other hand, I think, it is worthwhile getting acquainted with
the getattr-stuff, because this method can be useful in many contexts.

Anyway, thanks to all who participated in this thread. It taught me a
lot.



More information about the Python-list mailing list