On Sunday 26 October 2003 05:25 pm, Just van Rossum wrote: > Phillip J. Eby wrote: > > If we have a rebinding operator, I'd rather it be something > > considerably more visible than the presence or absence of a ':' on an > > assignment statement. > > I don't know, but somehow I don't have a problem spotting augmented > assignments, so I don't think := will be as hard to miss as you suggest. I agree -- := isn't any less "visible" than, say, -= . > > So far, all the examples have been downright scary in the > > invisibility of what's happening. Mostly, I can imagine some poor > > sap trying to debug a program that uses := and is missing one > > somewhere or has one where it's not intended -- and hoping that poor > > sap won't be me. :) > > How is that different from a '-=' that should have been a plain '='? > Also, if := is disallowed to rebind in the _same_ scope, this problem > would be spotted by the compiler. Not always (the = that should have been a := won't be, for example), but pretty often (more often than the errant -= will be;-). Worst case it's not any worse than the dreaded "typo in variable name" whereby somebody assigns to, e.g., "accounts__receivable" where they meant to assign to "accounts_receivable" -- people who are new to Python are terrified of that possibility, and demand declarations to take care of it, but long-time practitioners know it's not all that huge a danger. > > I've mostly stayed out of this discussion, but so far something like > > the scope(function).variable proposals, with perhaps a special case > > for scope(global) or scope(globals) seems to me like the way to go. > > It seems very Pythonic, in that it is explicit and calls attention to > > the fact that something special is going on, in a way that ':=' does > > not. > > The reverse argument can be made, too: := calls attention to the fact > that something is happening right there, whereas a declaration may be > many lines away. Right (that's part of why i do not like declarations!-), but the proposal Phillip is referring to would have "scope(foo).x = 23" ``right here'' just as "x := 23" would. Actually, speaking as the original author of the 'scope' proposal, I think I now prefer your := when taken in the simplest, most effective form -- took me a while to convince myself of that, but it grew on me. > > And 'scope' can be looked up in a manual more easily than ':=' > > can. Last, but not least, ':=' looks enough like normal assignment > > in other languages, that somebody just plain might not notice that > > they *need* to look it up. > > That's a good point. Well, if they're looking at a function that ONLY has := in isolation and no occurrence of = -- and their grasp of Python is so scarce that they don't realize = is Python's normal assignment. Doesn't seem like a particularly scary combination of circumstances to me, to be honest. Alex
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4