I have a working implementation for a new syntax which would make using keyword
arguments a lot nicer. Wouldn't it be awesome if instead of:
foo(a=a, b=b, c=c, d=3, e=e)
we could just write:
foo(*, a, b, c, d=3, e)
and it would mean the exact same thing? This would not just be
On Thu, Sep 06, 2018 at 12:15:46PM +0200, Anders Hovmöller wrote:
> I have a working implementation for a new syntax which would make
> using keyword arguments a lot nicer. Wouldn't it be awesome if instead
> of:
>
> foo(a=a, b=b, c=c, d=3, e=e)
>
> we could just write:
>
> foo(*,
On Thu, Sep 6, 2018 at 9:11 AM Steven D'Aprano wrote:
> On Thu, Sep 06, 2018 at 12:15:46PM +0200, Anders Hovmöller wrote:
>
> > I have a working implementation for a new syntax which would make
> > using keyword arguments a lot nicer. Wouldn't it be awesome if instead
> > of:
> >
> > foo(a=
I'm trying to see how it can be done with current python.
from somelib import auto
auto(locals(), function, 'a', 'b', 'c', d=5)
auto(locals(), function).call('a', 'b', 'c', d=5)
auto(locals(), function)('a', 'b', 'c', d=5)
auto(locals()).bind(function).call('a', 'b', 'c', d=5)
One of those synta
I have encountered situations like this, and generally I just use **kwargs
for non-critical and handle the parameter management in the body of the
function.
This also makes it easier to pass the arguments to another function. You
can use a dict comprehension to copy over the keys you want, then
Sorry, nevermind. I think I misunderstood the idea.
On Thu, Sep 6, 2018 at 9:56 AM Todd wrote:
> I have encountered situations like this, and generally I just use **kwargs
> for non-critical and handle the parameter management in the body of the
> function.
>
> This also makes it easier to pas
On Thursday, September 6, 2018 at 3:11:46 PM UTC+2, Steven D'Aprano wrote:
>
> On Thu, Sep 06, 2018 at 12:15:46PM +0200, Anders Hovmöller wrote:
>
> > I have a working implementation for a new syntax which would make
> > using keyword arguments a lot nicer. Wouldn't it be awesome if instead
>
Steven's point is the same as my impression. It's not terribly uncommon in
code I write or read to use the same name for a formal parameter (whether
keyword or positional) in the calling scope. But it's also far from
universal. Almost all the time where it's not the case, it's for a very
good rea
On 06/09/18 15:05, Anders Hovmöller wrote:
On Thursday, September 6, 2018 at 3:11:46 PM UTC+2, Steven D'Aprano wrote:
On Thu, Sep 06, 2018 at 12:15:46PM +0200, Anders Hovmöller wrote:
I have a working implementation for a new syntax which would make
using keyword arguments a lot nicer. Woul
Hi Anders
Thank you for your interesting message. I'm sure it's based on a real
need. You wrote:
> I have a working implementation for a new syntax which would make using
> keyword arguments a lot nicer. Wouldn't it be awesome if instead of:
> foo(a=a, b=b, c=c, d=3, e=e)
> we could just
On 09/06/2018 07:05 AM, Anders Hovmöller wrote:
On Thursday, September 6, 2018 at 3:11:46 PM UTC+2, Steven D'Aprano wrote:
On Thu, Sep 06, 2018 at 12:15:46PM +0200, Anders Hovmöller wrote:
Wouldn't it be awesome if [...]
No.
Heh. I did expect the first mail to be uncivil :P
Direct disag
I missed an important line of code. Here it is:
>>> aaa = 'telltale'
Once you have that, these will work:
>>> eval('aaa', fn.__globals__)
'telltale'
>>> __name__
'__main__'
>>> import sys
>>> getattr(sys.modules[__name__], 'aaa')
'telltale'
--
Jona
On Tue, Aug 28, 2018 at 6:37 PM Greg Ewing wrote:
>
> Guido van Rossum wrote:
> > we might propose (as the OP did) that this:
> >
> > a, b, c += x, y, z
> >
> > could be made equivalent to this:
> >
> > a += x
> > b += y
> > c += z
>
> But not without violating the principle that
>
> l
On Fri, Sep 7, 2018 at 4:11 AM, Franklin? Lee
wrote:
> On Tue, Aug 28, 2018 at 6:37 PM Greg Ewing
> wrote:
>>
>> Guido van Rossum wrote:
>> > we might propose (as the OP did) that this:
>> >
>> > a, b, c += x, y, z
>> >
>> > could be made equivalent to this:
>> >
>> > a += x
>> > b += y
>>
Hi Franklin Lee
Thank you for your message. You wrote:
> We can translate the original example:
> a, b, c += x, y, z
> to:
> a, b, c = target_list(a,b,c).__iadd__((x,y,z))
> where `target_list` is a virtual (not as in "virtual function") type
> for target list constructs.
Yes, we can.I t
On Thu, Sep 6, 2018 at 2:23 PM Chris Angelico wrote:
>
> On Fri, Sep 7, 2018 at 4:11 AM, Franklin? Lee
> wrote:
> > On Tue, Aug 28, 2018 at 6:37 PM Greg Ewing
> > wrote:
> >>
> >> Guido van Rossum wrote:
> >> > we might propose (as the OP did) that this:
> >> >
> >> > a, b, c += x, y, z
> >>
On Fri, Sep 7, 2018 at 4:38 AM, Franklin? Lee
wrote:
> The following are equivalent and compile down to the same code:
> a, b, c = lst
> [a, b, c] = lst
>
> The left hand side is not an actual list (even though it looks like
> one). The brackets are optional. The docs call the left hand si
Summary: I addressed the DEFINING problem. My mistake. Some rough
ideas for the CALLING problem.
Anders has kindly pointed out to me, off-list, that I solved the wrong
problem. His problem is CALLING the function fn, not DEFINING fn.
Thank you very much for this, Anders.
For calling, we can use h
n Thu, Sep 6, 2018 at 2:47 PM Chris Angelico wrote:
>
> On Fri, Sep 7, 2018 at 4:38 AM, Franklin? Lee
> wrote:
> > The following are equivalent and compile down to the same code:
> > a, b, c = lst
> > [a, b, c] = lst
> >
> > The left hand side is not an actual list (even though it looks l
On Thu, 6 Sep 2018 at 09:51 Ethan Furman wrote:
> On 09/06/2018 07:05 AM, Anders Hovmöller wrote:
> > On Thursday, September 6, 2018 at 3:11:46 PM UTC+2, Steven D'Aprano
> wrote:
> >> On Thu, Sep 06, 2018 at 12:15:46PM +0200, Anders Hovmöller wrote:
>
> >>> Wouldn't it be awesome if [...]
> >>
>
Rhodri James wrote:
that syntax looks at best highly misleading --
how many parameters are we passing? I don't like it at all.
Maybe something like this would be better:
f(=a, =b, =c)
Much more suggestive that you're passing a keyword argument.
As for whether consistent naming is a good
On Thursday, September 6, 2018 at 4:13:45 PM UTC+2, David Mertz wrote:
>
> Steven's point is the same as my impression. It's not terribly uncommon in
> code I write or read to use the same name for a formal parameter (whether
> keyword or positional) in the calling scope. But it's also far fro
>
>
> For comparison, my reaction did indeed involve awe. It was full of it,
> in fact :-p Sorry, but that syntax looks at best highly misleading --
> how many parameters are we passing? I don't like it at all.
>
(nitpick: we're passing arguments, not parameters)
I don't see how this could
On Thursday, September 6, 2018 at 6:51:12 PM UTC+2, Ethan Furman wrote:
>
> On 09/06/2018 07:05 AM, Anders Hovmöller wrote:
> > On Thursday, September 6, 2018 at 3:11:46 PM UTC+2, Steven D'Aprano
> wrote:
> >> On Thu, Sep 06, 2018 at 12:15:46PM +0200, Anders Hovmöller wrote:
>
> >>> Wouldn't it
> For calling, we can use
> https://docs.python.org/3/library/functions.html#locals
>
> >>> lcls = locals()
>
> >>> a = 'apple'
> >>> b = 'banana'
> >>> c = 'cherry'
>
> >>> dict((k, lcls[k]) for k in ('a', 'b', 'c'))
> {'b': 'banana', 'c': 'cherry', 'a'
> Maybe something like this would be better:
>
> f(=a, =b, =c)
>
Haha. Look at my PEP, it's under "rejected alternative syntax", because of
the super angry replies I got on this very mailing list when I suggested
this syntax a few years ago :P
I think that syntax is pretty nice persona
I think it makes more sense to remove the concept of positional only
parameters by slowly fixing the standard library. I've discussed the
existence of positional only with a few people and their response falls in
to some basic categories:
- disgust
- disbelief
- bargaining (it's not very common
On Thu, Sep 6, 2018 at 10:57 PM Anders Hovmöller wrote:
[..]
> I don't think that's a good look for Python :P
Anders,
Discussing something privately with "a few people", posting snarky
conclusions, and giving baseless recommendations isn't how we strive
to make decisions in Python. Please refra
On 01Mar2017 21:25, Serhiy Storchaka wrote:
On 28.02.17 23:17, Victor Stinner wrote:
My question is: would it make sense to implement this feature in
Python directly? If yes, what should be the syntax? Use "/" marker?
Use the @positional() decorator?
I'm strongly +1 for supporting positional-
On Fri, Sep 7, 2018 at 12:31 AM Anders Hovmöller wrote:
>
> Yury,
>
> I’m sorry if that came off badly, I was not attempting to be snarky. Text is
> hard and I know I’m not good in emails but rereading the text below I
> honestly can’t see why my honest attempt at describing my experience can be
30 matches
Mail list logo