New submission from Ezio Melotti <ezio.melo...@gmail.com>:

Python currently accepts global statements at the top level:
>>> global foo
>>>

Beside being a meaningless operation, this might lead unexperienced user
to make mistakes like:
>>> foo = 5
>>> global foo # make foo global
>>> def func():
...   print foo # access the global foo
...
>>> func()
5
>>> # it works!

"global foo" should raise a SyntaxError, similarly to what already
happens with "return":
>>> return foo
  File "<stdin>", line 1
SyntaxError: 'return' outside function

----------
components: Interpreter Core
messages: 95299
nosy: benjamin.peterson, ezio.melotti
priority: normal
severity: normal
status: open
title: global statements outside functions/methods should raise SyntaxError
type: feature request
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue7329>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to