Message153643
| Author |
techtonik |
| Recipients |
docs@python, techtonik |
| Date |
2012年02月18日.12:59:57 |
| SpamBayes Score |
3.964439e-06 |
| Marked as misclassified |
No |
| Message-id |
<1329569998.87.0.931536345344.issue14049@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
main.py below fails to execute local.py, 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.
http://docs.python.org/library/functions.html#execfile
---[cut main.py]---
values = {}
glavues = {}
execfile('local.py', glavues, values)
---[/cut]-----------
---[cut local.py]---
x = 1
def weird():
y = x + 1
return y
print weird()
---[/cut]-----------
Traceback (most recent call last):
File "main.py", line 5, in <module>
execfile('local.py', glavues, values)
File "local.py", line 7, in <module>
print weird()
File "local.py", line 5, in weird
y = x + 1
NameError: global name 'x' is not defined |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2012年02月18日 12:59:58 | techtonik | set | recipients:
+ techtonik, docs@python |
| 2012年02月18日 12:59:58 | techtonik | set | messageid: <1329569998.87.0.931536345344.issue14049@psf.upfronthosting.co.za> |
| 2012年02月18日 12:59:58 | techtonik | link | issue14049 messages |
| 2012年02月18日 12:59:57 | techtonik | create |
|