[Web-SIG] Iterator protocols.
Alan Kennedy
py-web-sig at xhaus.com
Mon Aug 30 23:05:08 CEST 2004
[Ian Bicking]
> Why? So long as he is catching the StopIteration that is in
> __builtin__, which may or may not be the object he originally put in
> there, it should all be fine. So maybe he should do:
>
> try:
> StopIteration
> except NameError:
> class StopIteration(Exception):
> pass
> __builtin__.StopIteration = StopIteration
> del StopIteration
:-)
Here's my implementation: minds think alike!
private void create_stop_iteration ( )
{
interp.exec(
"try:\n"+
" StopIteration\n"+
"except NameError:\n"+
" class StopIteration(Exception): pass\n"+
" import sys ; sys.add_package('org.python.core')\n"+
" from org.python.core import __builtin__\n"+
" __builtin__.StopIteration = StopIteration\n"+
" del StopIteration\n"
);
}
Regards,
Alan.
More information about the Web-SIG
mailing list