29 lines
1.0 KiB
Plaintext
29 lines
1.0 KiB
Plaintext
From: nascheme at m67.enme.ucalgary.ca (Neil Schemenauer)
|
|
Date: 16 Apr 1999 22:17:32 GMT
|
|
Subject: reval builtin
|
|
References: <7f36m6$koq@ds2.acs.ucalgary.ca> <001701be86e0$68574a60$589e2299@tim>
|
|
Message-ID: <7f8cts$cei@ds2.acs.ucalgary.ca>
|
|
X-UID: 147
|
|
|
|
On Thu, 15 Apr 1999 01:36:38 GMT, Tim Peters <tim_one at email.msn.com> wrote:
|
|
>def reval(string):
|
|
> return eval(string, {"__builtins__": {}})
|
|
|
|
Yes, I know that trick. It is much too easy and straight forward
|
|
though. ;)
|
|
|
|
>If you're determined to allow only literals (I don't see any harm in
|
|
>allowing e.g. 1+3), probably easiest to feed the string to the std parser
|
|
>module, then crawl over the AST looking for things to complain about.
|
|
|
|
I thought of doing that but suspected that it would be pretty slow. I
|
|
decided to waste some of my time and hand code a parser. I will
|
|
announce it in another post. Since your the compiler guy, you should
|
|
able to point out all the errors in my code, right?
|
|
|
|
picking-tim-bots-umm-brain?-ly y'rs - Neil
|
|
|
|
|
|
|
|
|