Re: [Python-ideas] Positional-only parameters

2018-09-10 Thread Abe Dillon
[Cameron Simpson] > I've been writing quite a few functions lately where it is reasonable for > a > caller to want to pass arbitrary keyword arguments, but where I also want > some > additional parameters for control purposes. I've run into this before and use the trailing '_' convention for

Re: [Python-ideas] Positional-only parameters

2018-09-10 Thread Abe Dillon
That looks great to me! I also think the '/' syntax looks fine and the pun works. If part of the motivation for position-only arguments was better performance and that motivation still holds water, then it makes sense to allow Python to support that optimization, but I would be happy with just a

Re: [Python-ideas] Positional-only parameters

2018-09-06 Thread Yury Selivanov
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

Re: [Python-ideas] Positional-only parameters

2018-09-06 Thread Cameron Simpson
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

Re: [Python-ideas] Positional-only parameters

2018-09-06 Thread Yury Selivanov
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

Re: [Python-ideas] Positional-only parameters

2018-09-06 Thread Anders Hovmöller
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

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Victor Stinner
I am thinking at writing a PEP, yes. I need time to think about it, find all corner cases. Maybe also include something for "optional parameter without default value". Don't expect it soon, I have some pending work to finish before :-) Victor Le 2 mars 2017 7:16 PM, "Brett Cannon"

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Brett Cannon
It seems all the core devs who have commented on this are in the positive (Victor, Yury, Ethan, Yury, Guido, Terry, and Steven; MAL didn't explicitly vote). So to me that suggests there's enough support to warrant writing a PEP. Are you up for writing it, Victor, or is someone else going to write

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Victor Stinner
2017-03-02 14:23 GMT+01:00 Steven D'Aprano : >> Replace "replace(self, old, new, count=-1, /)" with "replace(self, >> old, new[, count=-1])" (or maybe even not document the default >> value?). > > That isn't right. It would have to be: > > replace([self, old, new, count=-1]) >

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Victor Stinner
2017-03-01 21:52 GMT+01:00 Terry Reedy : > + 1 also. When people write a Python equivalent of a built-in function for > documentation or teaching purposes, they should be able to exactly mimic the > API. Yeah, Serhiy said basically the same thing: it's doable, but complex

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Steven D'Aprano
On Tue, Feb 28, 2017 at 10:17:31PM +0100, Victor Stinner wrote: > My question is: would it make sense to implement this feature [positional only parameters] > in Python directly? +0 on positional-only parameters. > If yes, what should be the syntax? Use "/" marker? I think that / makes a

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread אלעזר
Here's a proof-of-concept for the decorator. It does not address the issue of passing aliases to positional arguments to **kwargs - I guess this requires changes in the CPython's core. (Sorry about the coloring, that's how it's pasted) from inspect import signature, Parameter from functools

Re: [Python-ideas] Positional-only parameters

2017-03-02 Thread Ethan Furman
On 03/01/2017 11:41 PM, Stephan Houben wrote: I have a slight variant of the decorator proposal. Rather than specify a count, let the decorator implement the typeshed dunder convention: @positional_only def replace(self, __old, __new, count=-1): (I imagine this decorator would also

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Chris Barker
On Wed, Mar 1, 2017 at 2:16 PM, אלעזר wrote: > I like the idea, but I wanted to note that since it has no meaning from > the point of view of the defined function, it can be done with a magic > decorator, so new syntax is not required: > > @positional_only[:4] > def

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread אלעזר
On Wed, Mar 1, 2017 at 9:26 PM 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?

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread MRAB
On 2017-03-01 21:32, Ethan Furman wrote: On 03/01/2017 11:53 AM, Guido van Rossum wrote: FWIW in typeshed we've started using double leading underscore as a convention for positional-only parameters, e.g. here: https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L936 I

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Ethan Furman
On 03/01/2017 11:53 AM, Guido van Rossum wrote: FWIW in typeshed we've started using double leading underscore as a convention for positional-only parameters, e.g. here: https://github.com/python/typeshed/blob/master/stdlib/3/builtins.pyi#L936 I would much rather have a single '/' to denote

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Guido van Rossum
On Wed, Mar 1, 2017 at 11:25 AM, 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()

Re: [Python-ideas] Positional-only parameters

2017-03-01 Thread Serhiy Storchaka
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-only parameters. The main benefit to me is

Re: [Python-ideas] Positional-only parameters

2017-02-28 Thread M.-A. Lemburg
On 28.02.2017 22:17, Victor Stinner wrote: > Hi, > > For technical reasons, many functions of the Python standard libraries > implemented in C have positional-only parameters. Keyword argument handling is comparatively slow and rarely needed for non-optional positional parameters of built-ins.

Re: [Python-ideas] Positional-only parameters

2017-02-28 Thread Ethan Furman
https://www.python.org/dev/peps/pep-0457/ https://mail.python.org/pipermail/python-dev/2014-January/131865.html -- ~Ethan~ ___ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct:

Re: [Python-ideas] Positional-only parameters

2017-02-28 Thread Frazer McLean
On 28 Feb 2017, at 22:17, Victor Stinner wrote: I just noticed a module on PyPI to implement this behaviour on Python functions: https://pypi.python.org/pypi/positional Tangential to the main topic, but this module doesn’t enforce positional-only arguments. It allows you enforce

Re: [Python-ideas] Positional-only parameters

2017-02-28 Thread Yury Selivanov
I'm +0.5 to add positional-only parameters. Pros: * A lot of people don't know what '/' currently means in functions signatures rendered by `help` and docs. Because it's not a real syntax, it's really hard to find what it means. * Some APIs do look better with positional-only parameters,