<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
> However, I believe this is a case where the cognitive cost of changing <br>> the status quo isn't worthwhile. New Python users can be taught very <br>> quickly that assigning to a variable from a different scope requires a <br>> global or nonlocal declaration.<br> ><br>> While existing users could be taught easily enough that that was no <br>> longer necessary for augmented assignment, how much real world code <br>> would actually benefit? (now, Paul Graham's accumulator hobby horse <br>> doesn't count as real world code)<br><br>I believe it would be simpler to learn that variables are _only_ local if bound with the assignment operator. I view the augmented assignment operators as different beasts. This patch doesn't quite meet its goals in that respect. I'd like to further the locality of a variable to "A variable is local if, and only if, it is first referenced as the left hand side of an assignment on all code paths." This patch fails to set that rule<br><br>For example,<br><br>def f(x):<br>    a.append(x)<br>    if len(a)>5:a=[5]<br><br>If a is bound as a local, this throws an UnboundLocalError. Why then is it not set to try the global namespace, that place we cannot be so certain of the exception in?<br><br>It comes down to the view of UnboundLocalError as a feature or a bug<br>                                       <br /><hr />À gagner : votre photo sur Bing.ca durant la fête du Canada  <a href='http://go.microsoft.com/?linkid=9734390' target='_new'>Soumettez une photo maintenant!</a></body>
</html>