Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #76250 > unrolled thread

Re: what is the "/" mean in __init__(self, /, *args, **kwargs) ?

Started byEthan Furman <ethan@stoneleaf.us>
First post2014-08-13 19:20 -0700
Last post2014-08-13 19:20 -0700
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: what is the "/" mean in __init__(self, /, *args, **kwargs) ? Ethan Furman <ethan@stoneleaf.us> - 2014-08-13 19:20 -0700

#76250 — Re: what is the "/" mean in __init__(self, /, *args, **kwargs) ?

FromEthan Furman <ethan@stoneleaf.us>
Date2014-08-13 19:20 -0700
SubjectRe: what is the "/" mean in __init__(self, /, *args, **kwargs) ?
Message-ID<mailman.12959.1407982808.18130.python-list@python.org>
On 08/13/2014 07:01 PM, luofeiyu wrote:
>>>> help(int.__init__)
> Help on wrapper_descriptor:
>
> __init__(self, /, *args, **kwargs)
>      Initialize self.  See help(type(self)) for accurate signature.
>
> what is the "/" mean in __init__(self, /, *args, **kwargs) ?

The '/' means that all arguments before it must be positional only.  This looks like an artifact of the new Argument 
Clinic for C code.

For example, if this also worked at the Python level, you could say:

    def some_func(this, that, /, spam, eggs, *, foo, bar):
       pass

Meaning that the first two parameters could not be specified by name, the next two could be either name or position, and 
the last two by name only.

Oh, and the * is valid Python now (the / is not -- it's solely a documentation feature at this point).

--
~Ethan~

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web