Gerald Britton wrote:
> On Wed, Feb 3, 2010 at 2:59 PM, Terry Reedy wrote:
>> On 2/3/2010 3:30 AM, Simon zack wrote:
>>>
>>> hi,
>>> I'm not sure how I can use exec within a function correctly
>>> here is the code i'm using:
>>>
>>> def a():
>>> exec('b=1')
>>> print(b)
>>>
>>> a()
>>>
>>> this w
I get no error:
>>> def a():
... exec('b=1')
... print(b)
...
>>> a()
1
>>>
On Wed, Feb 3, 2010 at 2:59 PM, Terry Reedy wrote:
> On 2/3/2010 3:30 AM, Simon zack wrote:
>>
>> hi,
>> I'm not sure how I can use exec within a function correctly
>> here is the code i'm using:
>>
>> def a():
>>
On 2/3/2010 3:30 AM, Simon zack wrote:
hi,
I'm not sure how I can use exec within a function correctly
here is the code i'm using:
def a():
exec('b=1')
print(b)
a()
this will raise an error, but I would like to see it outputting 1
Always **copy and paste** **complete error tracebac
hi,
I'm not sure how I can use exec within a function correctly
here is the code i'm using:
def a():
exec('b=1')
print(b)
a()
this will raise an error, but I would like to see it outputting 1
thanks
smk
--
http://mail.python.org/mailman/listinfo/python-list