How to use the exec statement
jb at yahoo.de
Mon Oct 7 17:50:06 CEST 2002
<posted & mailed>
Alex Martelli wrote:
> JB wrote:
>> Alex Martelli wrote:
>> Thx, now everything works fine (but for catching user
>> errors that raise exceptions, which I have not
>> implemented yet).
> Good to have been of use!
> Since you want to catch just about every error the user
> could make, you probably want a try/except with a very
> broad condition... in fact I fear you need a
> condition-less except (always a problem) since the user
> could raise a string, and even "except Exception:" won't
> catch THAT... that's rather a fragile thing to do (as it
> may mask any programming error) but it's hard to think of
Well, I could preprocess the string that is given to exec. I
am thinking about introducing '<---' instead of '=' anyway.
Then only assignments, function calls and function
definitions would be allowed.
But even so, I cannot catch every error. But I could use
except without a name, couldn't I? like in
Then if I split the string that is give to exec I can even
tell in which line the error occured.
Is this sensible?
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
More information about the Python-list