Message80841
I am not an expert. But for me it is much better.
If you cannot delete the global variable in a function (del makes the
variable local anyway). So trying to delete a global variable should
raise an exception "Cannot delete a global variable" or something like
that. In a function variable should be global till the place when you
define a local one.
Example:
a='Something'
def f():
print a #prints the global variable a
del a #Make an exception that a is global so it cannot be deleted
a='anotherthing' #make a local a
print a #print local a
del a #delete local a
print a #print global a
f()
Also, if there are two variable (global and local) with seme name, there
should be a way to access either of them like 'print loc(a)' and 'print
glob(a)'. This is just a suggestion
Another way of resolving the problem would be making it impossible to
make a local variable when there is anothe one with the same name.
David W. Lambert pisze:
> David W. Lambert <lambertdw@corning.com> added the comment:
>
> The alternative is unreasonable. I doubt you'd be happy with this:
>
>
> a = 'Something'
>
> def variable_both_global_and_local()->Exception('No good!'):
> del a # delete a from global name space
> a = 'anotherthing' # define a in local name space
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue5092>
> _______________________________________
>
>
> |
|
Date |
User |
Action |
Args |
2009-01-30 22:52:32 | Orlowski | set | recipients:
+ Orlowski, loewis, LambertDW |
2009-01-30 22:52:30 | Orlowski | link | issue5092 messages |
2009-01-30 22:52:29 | Orlowski | create | |
|