[Python-Dev] PEP for Better Control of Nested Lexical Scopes

Mark Russell mrussell at verio.net
Tue Feb 21 23:56:34 CET 2006


On 21 Feb 2006, at 21:13, Ian Bicking wrote:
> By rebinding operator, does that mean it is actually an operator?   
> I.e.:
>
>    # Required assignment to declare?:
>    chunk = None
>    while chunk := f.read(1000):
>        ...

No, I think that "x := y" should be a statement not an expression  
(i.e. just like "x = y" apart from the treatment of bindings).

I'd be inclined to require that the target of := be already bound, if  
only to prevent people randomly using ":=" in places where it's not  
required.

In a new language I would probably also make it an error to use = to  
do rebinding (i.e. insist on = for new bindings, and := for  
rebindings).  But that's obviously not reasonable for python.

Mark Russell


More information about the Python-Dev mailing list