+1 on the idea.
Sometimes early binding is needed, sometimes late binding is needed. So
Python should provide both. QED 😁
I'm not keen on the
var = > expr
syntax. IMO the arrow is pointing the wrong way. expr is assigned to var.
Some possible alternatives, if there is no technical reason they
wouldn't work (as far as I know they are currently a syntax error, and
thus unambiguous, inside a function header, unless annotations change
things. I know nothing about annotations):
var <= exp # Might be confused with less-than-or-equals
var := expr # Reminiscent of the walrus operator in other contexts.
# This might be considered a good thing or
a bad thing.
# Possibly too similar to `var = expr'
var : expr # Less evocative. Looks like part of a dict display.
var <- expr # Trailing `-` is confusing: is it part of (-expr) ?
var = <expr> # Hm. At least it's clearly distinct from `var=expr`.
var << expr # Ditto.
(var = expr)
[var = expr] # Ditto
And as I'm criticising my own suggestions, I'll do the same for the ones
in the PEP:
def bisect(a, hi=:len(a)): # Just looks weird, doesn't suggest anything to
me
def bisect(a, hi?=len(a)): # Hate question marks (turning Python into
Perl?)
# Ditto for using $ or % or ^ or &
def bisect(a, hi!=len(a)): # Might be confused with not-equals
def bisect(a, hi=\len(a)): # `\` looks like escape sequence or end of line
# What if you wanted to break a long line at
that point?
def bisect(a, hi=`len(a)`): # Backquotes are fiddly to type. Is `
len(a) ` allowed?
def bisect(a, hi=@len(a)): # Just looks weird, doesn't suggest anything to
me
My personal current (subject to change) preference would be `var := expr`.
All this of course is my own off-the-cuff subjective reaction.
Y M M (probably will) V.
Best wishes
Rob Cliffe
On 23/10/2021 23:08, Chris Angelico wrote:
On Sun, Oct 24, 2021 at 9:05 AM Ethan Furman <et...@stoneleaf.us> wrote:
On 10/23/21 2:23 PM, Chris Angelico wrote:
> It seems like there's broad interest in this, but a lot of details to
> nut out. I think it may be time for me to write up a full PEP. Guido,
> if I'm understanding recent SC decisions correctly, a PEP editor can
> self-sponsor, correct?
Of all people, PEP editor or not, you should be able to self-sponsor. ;-)
But if you need one, I'm happy to step up.
Heh. Thanks. :) I'll start writing then.
ChrisA
not a core dev, although someone recently credited me using that descriptor
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/ZCRBGUKPCBTAJPG6HKZVIAO2SYNX3Q2H/
Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/K5NVQTNKPJRNG5ZED5LYN7BCBXVVXLHE/
Code of Conduct: http://python.org/psf/codeofconduct/