use strings to call functions
Bruno Desthuilliers
bruno.42.desthuilliers at websiteburo.invalid
Wed Feb 10 06:55:44 EST 2010
Klaus Neuner a écrit :
>
> All right, I admit that eval() is evil and should never be used.
Can you tell the difference between your above statement and the following:
"""
eval() is potentially dangerous and can make code harder to debug. 99%
of the proposed use case for eval() are covered by simpler, less
dangerous and easier to understand solutions, so the GoodPractice(tm) is
to favor these solutions and only use eval() - with appropriate care -
for the remaining 1% _real_ use case.
"""
If you can't tell the difference, then you're about as (im)mature as my
13 year old son and it might eventually be time to grow up.
> The same applies to knives. You shouldn't use them. You
> shouldn't even use them in your own kitchen. A man might enter your
> kitchen, take your knife away and use it against you.
Knives - specially the kind I use in my kitchen - are indeed potentially
dangerous, and I indeed had to educate my son so he wouldn't do anything
stupid with them - like pointing a knife at someone, running across the
house with a knife in his hand, or using them instead of a more
appropriate tool.
The probability that someone will enter your kitchen and use one of your
knives against you, while not null, are low enough to be ignored IMHO. I
whish I could say the same about script kiddies or more educated (and
dangerous) bad guys trying to attack our servers.
But you obviously never had to neither fix a compromised server nor
raise a kid - else you'd now better. Hopefully you didn't raise my kid -
now I just pray none of your code will ever run on our servers.
More information about the Python-list
mailing list