Loading and executing an arbitrary Python script from within Python

Steven Taschuk staschuk at telusplanet.net
Mon Jul 28 16:37:34 EDT 2003


Quoth Raymond Arthur St. Marie II of III :
  [...]
> Did I get the concept wrong about using
> a generater in a try section? Is this code legal anyone?
> 
> Or does this only pertain to the yeild statement in a try.

The prohibition is on yield statements in the try section of a
try-finally statement.  The posted code is fine.

(This is prohibited because there is no guarantee that execution
will ever return to the generator after the yield -- the caller
might never call .next() again -- and so the finally block might
never be executed.  This was judged too grave a violation of
try/finally's semantics to permit.)

-- 
Steven Taschuk                          staschuk at telusplanet.net
"Its force is immeasurable.  Even Computer cannot determine it."
                           -- _Space: 1999_ episode "Black Sun"





More information about the Python-list mailing list