Author techtonik
Recipients docs@python, techtonik
Date 2012-02-18.12:59:57
SpamBayes Score 3.96444e-06
Marked as misclassified No
Message-id <>
Content below fails to execute, which work ok (outputs '2') when processed directly in console.

Docs are not explaining anything. They spread fear and uncertainty around locals, but nothing is said why globals may fail.

values = {}
glavues = {}
execfile('', glavues, values)

x = 1
def weird():
    y = x + 1
    return y
print weird()

Traceback (most recent call last):
  File "", line 5, in <module>
    execfile('', glavues, values)
  File "", line 7, in <module>
    print weird()
  File "", line 5, in weird
    y = x + 1
NameError: global name 'x' is not defined
Date User Action Args
2012-02-18 12:59:58techtoniksetrecipients: + techtonik, docs@python
2012-02-18 12:59:58techtoniksetmessageid: <>
2012-02-18 12:59:58techtoniklinkissue14049 messages
2012-02-18 12:59:57techtonikcreate