Does eval has the same features as Perl's?

J. Clifford Dyer webmaster at cacradicalgrace.org
Mon Jan 22 15:13:02 EST 2007


The python editor won't "get exit."  It will raise an exception.  With
or without an eval, you can catch the exception.

try:
    x = 1/0
except ZeroDivisionError:
    x = "infinity"


Jm lists wrote:
> Hello members,
> 
> I want to know does the "eval" in python have the same features as in
> Perl (capture errors)?
> 
> For example,in perl I can wrote:
> 
> $re = eval { 1 / 0 };
> 
> Though 1/0 is a fatal error but since it's in "eval" block so the perl
> interpreter doesn't get exit.
> 
> Thanks again.



More information about the Python-list mailing list