This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Orlowski
Recipients LambertDW, Orlowski, loewis
Date 2009-01-30.22:52:29
SpamBayes Score 1.9694725e-07
Marked as misclassified No
Message-id <4983849F.4070800@genesilico.pl>
In-reply-to <1233326425.97.0.690405797973.issue5092@psf.upfronthosting.co.za>
Content
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>
> _______________________________________
> 
> 
>
History
Date User Action Args
2009-01-30 22:52:32Orlowskisetrecipients: + Orlowski, loewis, LambertDW
2009-01-30 22:52:30Orlowskilinkissue5092 messages
2009-01-30 22:52:29Orlowskicreate