"Steve Holden" <sholden at holdenweb.com> writes: >> >> :var = value # var in module scope >> :scope:var = value # var in named enclosing scope >> >> An advantage of this notation is that it can be used anywhere, not >> just in an assignment. This has primary value for people reading the >> code -- if you have a fairly large class method that uses a module >> variable (not by assigning it) somewhere in the middle, writing it >> :var means the reader knows to go look for the assignment way up top. >> This should obviously be optional, to preserve backward compatibility. >> > However, its use in such expressions as > > sublist = lst[:var] > > would lead to substantial ambiguities, right? I suppose it would. Unfortunately, there's no other punctuation mark that can really be used for the purpose -- I think both $ and @ (suggested elsewhere in response to a similar proposal) have too many countervailing connotations. Witness e.g. the suggestion last week that $ become magic in string % dict notation. Py-in-the-sky suggestion: make the slice separator character be ; instead of :. (Half serious.) Somewhat warty suggestion: take lst[:var] to be a slice, but lst[(:var)] to be a global variable reference. And lst[:(:var)] to be a slice on a global, etc. etc. Better ideas solicited. zw
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