Steven W. Orr wrote:
> I have this which works:
>
> #! /usr/bin/python
> strfunc = """
> def foo( a ):
> print 'a = ', a
> """
> exec strfunc
> globals()['foo'] = foo
> foo( 'Hello' )
>
> and this which does not:
>
> #! /usr/bin/python
> import new
> strfunc = """
> def foo( a ):
> pr
I have this which works:
#! /usr/bin/python
strfunc = """
def foo( a ):
print 'a = ', a
"""
exec strfunc
globals()['foo'] = foo
foo( 'Hello' )
and this which does not:
#! /usr/bin/python
import new
strfunc = """
def foo( a ):
print 'a = ', a
"""
co = compile ( strfunc, '', 'exec' )
exe