On Sun, Oct 24, 2021 at 3:43 PM Steven D'Aprano wrote:
> So far, I dislike all of those syntaxes (regardless of which symbol is
> used as the modifier). They are all predicated on the idea that this is
> a new sort of assignment, which I think is the wrong way to think about
> it. I think that
On 2021-10-23 09:07, Chris Angelico wrote:
Proposal: Proper syntax and support for late-bound argument defaults.
def spaminate(thing, count=:thing.getdefault()):
...
I'm -1 on it.
For me the biggest problem with this idea is that it only handles a
subset of cases, namely
Let's talk about the choice of spelling. So far, most of the suggested
syntaxes have modified the assignment symbol `=` using either a prefix
or a suffix. I'm going to use '?' as the generic modifier. So the
parameter will look like:
# Modifier as a prefix
param?=expression
On Sat, Oct 23, 2021 at 9:21 PM Chris Angelico wrote:
> On Sun, Oct 24, 2021 at 2:52 PM David Mertz, Ph.D.
> wrote:
> >
> > On Sat, Oct 23, 2021, 11:46 PM David Mertz, Ph.D.
> >>>
> >>> def f(x=defer: a + b):
> >>> a, b = 3, 5
> >>> return x
> >>>
> >>> Would this return 8, or a
On Sun, Oct 24, 2021 at 2:52 PM David Mertz, Ph.D.
wrote:
>
> On Sat, Oct 23, 2021, 11:46 PM David Mertz, Ph.D.
>>>
>>> def f(x=defer: a + b):
>>> a, b = 3, 5
>>> return x
>>>
>>> Would this return 8, or a defer-expression? If 8, then the scope isn't
>>> truly dynamic, since there's no
On Sat, Oct 23, 2021, 11:46 PM David Mertz, Ph.D.
> def f(x=defer: a + b):
>> a, b = 3, 5
>> return x
>>
>> Would this return 8, or a defer-expression? If 8, then the scope isn't
>> truly dynamic, since there's no way to keep it deferred until it moves to
>> another scope. If not 8, then
On 2021-10-24 at 13:23:51 +1100,
Steven D'Aprano wrote:
> On Sat, Oct 23, 2021 at 02:54:54PM -0700, 2qdxy4rzwzuui...@potatochowder.com
> wrote:
>
> [...]
> > > The function header is a syntactic construct - the "def" line, any
> > > decorators, annotations, etc.
> >
> > If you mean that def
On Sat, Oct 23, 2021, 11:28 PM Chris Angelico wrote:
> > So stawman proposal:
> >
> > def fun(seq, low=0, high=defer: len(seq)):
> > assert low < high
> > # other stuff...
> >
> > Where the implication here is that the "defer expression" creates a
> dynamic scope.
>
> At what point
On Sun, Oct 24, 2021 at 2:21 PM David Mertz, Ph.D.
wrote:
>
> On Sat, Oct 23, 2021, 10:58 PM Steven D'Aprano
>>
>> > ... On the other hand, if this could express a much more general deferred
>> > computation, I'd be really enthusiastic (subject to syntax and behavioral
>> > details).
>> >
>> >
On Sat, Oct 23, 2021, 10:58 PM Steven D'Aprano
> > ... On the other hand, if this could express a much more general
> deferred computation, I'd be really enthusiastic (subject to syntax and
> behavioral details).
> >
> > However, I recognize that a new general "dynamically scoped lambda"
> would
On Sun, Oct 24, 2021 at 1:53 PM Steven D'Aprano wrote:
>
> On Sun, Oct 24, 2021 at 01:16:02PM +1100, Chris Angelico wrote:
>
> > What I'm more often seeing is cases that are less obviously a
> > late-binding, but where the sentinel is replaced with the "real" value
> > at the point where it's
On Sat, Oct 23, 2021 at 7:55 PM Steven D'Aprano wrote:
>
> And is it really a problem if we delay the late-binding to the point
> where the value is actually needed? ...
[in that csse] I would stick to manual late-
> binding using None, and only evaluate it as needed.
>
> Maybe this
--- Bruce
On Sat, Oct 23, 2021 at 7:55 PM Chris Angelico wrote:
> On Sun, Oct 24, 2021 at 1:48 PM Bruce Leban wrote:
> >
> >
> > On Sat, Oct 23, 2021 at 6:23 PM Jelle Zijlstra
> wrote:
> >>
> >> In the PEP's example:
> >>
> >> def bisect_right(a, x, lo=0, hi=>len(a), *, key=None):
> >>
>
On Sun, Oct 24, 2021 at 05:49:50AM +0400, David Mertz, Ph.D. wrote:
> ... On the other hand, if this could express a much more general deferred
> computation, I'd be really enthusiastic (subject to syntax and behavioral
> details).
>
> However, I recognize that a new general "dynamically scoped
On Sat, Oct 23, 2021 at 7:00 PM Steven D'Aprano wrote:
> I challenge that assertion. I've never knowingly seen a function where
> the late binding is "buried deeper in the function", certainly not deep
> enough that it is not obvious. It is a very strong convention that such
> late binding
On Sun, Oct 24, 2021 at 01:16:02PM +1100, Chris Angelico wrote:
> What I'm more often seeing is cases that are less obviously a
> late-binding, but where the sentinel is replaced with the "real" value
> at the point where it's used, rather than up the top of the function.
Got any examples you
On Sun, Oct 24, 2021 at 1:48 PM Bruce Leban wrote:
>
>
> On Sat, Oct 23, 2021 at 6:23 PM Jelle Zijlstra
> wrote:
>>
>> In the PEP's example:
>>
>> def bisect_right(a, x, lo=0, hi=>len(a), *, key=None):
>>
>> This reads to me like we're putting "hi" into "len(a)", when it's in fact
>> the
On Sat, Oct 23, 2021 at 6:23 PM Jelle Zijlstra
wrote:
> In the PEP's example:
>
> def bisect_right(a, x, lo=0, hi=>len(a), *, key=None):
>
> This reads to me like we're putting "hi" into "len(a)", when it's in fact
> the reverse.
>
I think in most cases what's on the right side will be
Love the proposed syntax, it's clear and visible without being verbose. I was a
bit worried with the "=:" syntax as, at first glance, it can be easily mistaken
with a regular "=" but you can't miss "=>". Also, I think the syntax fits
really well with the meaning of the operator, which is
On Sat, Oct 23, 2021 at 02:54:54PM -0700, 2qdxy4rzwzuui...@potatochowder.com
wrote:
[...]
> > The function header is a syntactic construct - the "def" line, any
> > decorators, annotations, etc.
>
> If you mean that def statements and decorators run at compile time, then
> I agree. If you mean
On Sun, Oct 24, 2021 at 1:12 PM Ricky Teachey wrote:
>
> This might be a dumb question but is the context built only left to right? Or
> will this be legal?
>
> def f(a, *, b=:c, c=:b):
> print(f"{a=} {b=} {c=}")
>
> >>> f(1, b=2)
> a=1 b=2 c=2
>
> >>> f(1, c=2)
> a=1 b=2 c=2
>
That's
On Sun, Oct 24, 2021 at 1:00 PM Steven D'Aprano wrote:
>
> On Sun, Oct 24, 2021 at 06:54:36AM +1100, Chris Angelico wrote:
>
> [...]
> > Teaching moment. Currently, the equivalent second function would be this:
> >
> > def f2(l=None):
> > if l is None: l = []
> > l.append(4)
> >
This might be a dumb question but is the context built only left to right?
Or will this be legal?
def f(a, *, b=:c, c=:b):
print(f"{a=} {b=} {c=}")
>>> f(1, b=2)
a=1 b=2 c=2
>>> f(1, c=2)
a=1 b=2 c=2
___
Python-ideas mailing list --
On Sun, Oct 24, 2021 at 12:44 PM Rob Cliffe wrote:
> I'm not keen on the
> var = > expr
> syntax. IMO the arrow is pointing the wrong way. expr is assigned to var.
That's definitely open to discussion.
> Some possible alternatives, if there is no technical reason they
> wouldn't work (as
On Sun, Oct 24, 2021 at 06:54:36AM +1100, Chris Angelico wrote:
[...]
> Teaching moment. Currently, the equivalent second function would be this:
>
> def f2(l=None):
> if l is None: l = []
> l.append(4)
> return l
>
> And the whole "early bind or late bind" question is there just
>From what I've seen so far, I'm -0 on this.
I understand the pattern it addresses, but it doesn't feel all that common,
nor that hard to address with the existing sentinel-check pattern alien in
the PEP draft.
This just doesn't feel big enough to merit it's own syntax.
... On the other hand,
On Sun, Oct 24, 2021 at 12:10 PM Steven D'Aprano wrote:
>
> Eight hours from the initial post on Python-Ideas, to a PEP, with just
> eight responses from six people. Is that some sort of a record?
>
> And in the wee hours of the morning too (3am to 11am local time). I
> thought my sleep habits
El sáb, 23 oct 2021 a las 12:57, Guido van Rossum ()
escribió:
> I like that you're trying to fix this wart! I think that using a different
> syntax may be the only way out. My own bikeshed color to try would be `=>`,
> assuming we'll introduce `(x) => x+1` as the new lambda syntax, but I can
>
Eight hours from the initial post on Python-Ideas, to a PEP, with just
eight responses from six people. Is that some sort of a record?
And in the wee hours of the morning too (3am to 11am local time). I
thought my sleep habits were bad. Do you not sleep any more? :-)
--
Steve
Incorporates comments from the thread we just had.
Is anyone interested in coauthoring this with me? Anyone who has
strong interest in seeing this happen - whether you've been around the
Python lists for years, or you're new and interested in getting
involved for the first time, or anywhere in
On Sun, Oct 24, 2021 at 9:05 AM Ethan Furman 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
On Sun, Oct 24, 2021 at 8:56 AM <2qdxy4rzwzuui...@potatochowder.com> wrote:
>
> On 2021-10-24 at 06:54:36 +1100,
> Chris Angelico wrote:
>
> > On Sun, Oct 24, 2021 at 6:18 AM <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > > > The expression would be evaluated in the function's context, having
>
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
On 2021-10-24 at 06:54:36 +1100,
Chris Angelico wrote:
> On Sun, Oct 24, 2021 at 6:18 AM <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > > The expression would be evaluated in the function's context, having
> > > available to it everything that the function has. Notably, this is NOT
> > > the
On Sun, Oct 24, 2021 at 7:58 AM Bruce Leban wrote:
>
> On Sat, Oct 23, 2021 at 12:56 PM Guido van Rossum wrote:
>>
>> I like that you're trying to fix this wart! I think that using a different
>> syntax may be the only way out. My own bikeshed color to try would be `=>`,
>> assuming we'll
On Sun, Oct 24, 2021 at 6:55 AM Guido van Rossum wrote:
>
> I like that you're trying to fix this wart! I think that using a different
> syntax may be the only way out. My own bikeshed color to try would be `=>`,
> assuming we'll introduce `(x) => x+1` as the new lambda syntax, but I can see
>
On Sat, Oct 23, 2021 at 12:56 PM Guido van Rossum wrote:
> I like that you're trying to fix this wart! I think that using a different
> syntax may be the only way out. My own bikeshed color to try would be `=>`,
> assuming we'll introduce `(x) => x+1` as the new lambda syntax, but I can
> see
On Sat, 23 Oct 2021 at 17:09, Chris Angelico wrote:
>
> Proposal: Proper syntax and support for late-bound argument defaults.
>
> def spaminate(thing, count=:thing.getdefault()):
> ...
>
> def bisect(a, x, lo=0, hi=:len(a)):
> if lo < 0:
> raise ValueError('lo must be
On Sun, Oct 24, 2021 at 6:18 AM <2qdxy4rzwzuui...@potatochowder.com> wrote:
> > The expression would be evaluated in the function's context, having
> > available to it everything that the function has. Notably, this is NOT
> > the same as the context of the function definition, but this is only
>
I like that you're trying to fix this wart! I think that using a different
syntax may be the only way out. My own bikeshed color to try would be `=>`,
assuming we'll introduce `(x) => x+1` as the new lambda syntax, but I can
see problems with both as well :-).
--
--Guido van Rossum
On 2021-10-24 at 03:07:45 +1100,
Chris Angelico wrote:
> def bisect(a, x, lo=0, hi=None):
> if lo < 0:
> raise ValueError('lo must be non-negative')
> if hi is None:
> hi = len(a)
>
> It's clear what value lo gets if you omit it. It's less clear what hi
> gets. And the
On Sun, Oct 24, 2021 at 4:12 AM Ethan Furman wrote:
>
> On 10/23/21 9:44 AM, Chris Angelico wrote:
>
> > Feel free to propose an improvement to the syntax. Whatever spelling
> > is ultimately used, this would still be of value.
>
> def bisect(a, x, lo=0, hi?=len(a)):
>
Ah, okay. I had
>From my phone.
An important thing about def x and class A is that the strings x and A are
made available to the constructor for x and A respectively. The same is not
true for x=val.
Jonathan
___
Python-ideas mailing list -- python-ideas@python.org
To
Why would anyone want to type:
def variable = value
when they could just type:
variable = value
instead? Perhaps if I was being paid by the character typed...
def my__really__good__variable = ( value )# Assign value to
my__really__good__variable.
*wink*
But all joking
On 10/23/21 9:44 AM, Chris Angelico wrote:
> Feel free to propose an improvement to the syntax. Whatever spelling
> is ultimately used, this would still be of value.
def bisect(a, x, lo=0, hi?=len(a)):
--
~Ethan~
___
Python-ideas mailing list --
Hello people,
I was thinking of a "def" statement in Python.
Its really weird that it can define only method, since it means "define".
It shouldn't be hard to detect if this is a variable or a method, because
method needs "()" to have arguments(even if there are zero of them),
and defining
On Sun, Oct 24, 2021 at 3:26 AM Ethan Furman wrote:
>
> On 10/23/21 9:07 AM, Chris Angelico wrote:
>
> > Proposal: Proper syntax and support for late-bound argument defaults.
>
> I like the proposal.
>
> > def spaminate(thing, count=:thing.getdefault()):
> > ...
> >
> > def bisect(a, x,
On 10/23/21 9:07 AM, Chris Angelico wrote:
> Proposal: Proper syntax and support for late-bound argument defaults.
I like the proposal.
> def spaminate(thing, count=:thing.getdefault()):
> ...
>
> def bisect(a, x, lo=0, hi=:len(a)):
> if lo < 0:
> raise ValueError('lo must
Spun off from PEP 505 thread on python-dev.
One of the weaker use-cases for None-coalescing is function default
arguments, where the technical default is None but the function wants
to use some other value instead. This is a weak argument in favour of
None-coalescing because only a small set of
49 matches
Mail list logo