Re: [Python-Dev] global variable modification in functions [Re: elimination of scope bleeding of iteration variables]

2006-05-02 Thread Nick Coghlan
Phillip J. Eby wrote: And for the case where the compiler can tell the variable is accessed before it's defined, there's definitely something wrong. This code, for example, is definitely missing a global and the compiler could in principle tell: foo = 1 def bar():

Re: [Python-Dev] global variable modification in functions [Re: elimination of scope bleeding of iteration variables]

2006-05-01 Thread Oleg Broytmann
On Sun, Apr 30, 2006 at 10:47:07PM -0500, Ben Wing wrote: foo = 1 def set_foo(): foo = 2 PyLint gives a warning here local foo shadows global variable. Oleg. -- Oleg Broytmannhttp://phd.pp.ru/[EMAIL PROTECTED] Programmers don't die, they just

Re: [Python-Dev] global variable modification in functions [Re: elimination of scope bleeding of iteration variables]

2006-05-01 Thread Guido van Rossum
On 4/30/06, Ben Wing [EMAIL PROTECTED] wrote: [1] ideally, change this behavior, either for 2.6 or 3.0. maybe have a `local' keyword if you really want a new scope. [2] until this change, python should always print a warning in this situation. [3] the current 'UnboundLocal' exception should

Re: [Python-Dev] global variable modification in functions [Re: elimination of scope bleeding of iteration variables]

2006-05-01 Thread Phillip J. Eby
At 07:32 AM 5/1/2006 -0700, Guido van Rossum wrote: On 4/30/06, Ben Wing [EMAIL PROTECTED] wrote: [1] ideally, change this behavior, either for 2.6 or 3.0. maybe have a `local' keyword if you really want a new scope. [2] until this change, python should always print a warning in this

Re: [Python-Dev] global variable modification in functions [Re: elimination of scope bleeding of iteration variables]

2006-05-01 Thread Guido van Rossum
On 5/1/06, Phillip J. Eby [EMAIL PROTECTED] wrote: While I agree that item #1 is a non-starter, it seems to me that in the case where the compiler statically knows a name is being bound in the module's globals, and there is a *non-argument* local variable being bound in a function body, the