Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #76250
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <ethan@stoneleaf.us> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'argument': 0.05; 'position,': 0.05; 'initialize': 0.07; 'level,': 0.07; '*args,': 0.09; 'arguments': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'oh,': 0.09; '~ethan~': 0.09; 'python': 0.11; 'def': 0.12; '"/"': 0.16; "'/'": 0.16; '**kwargs)': 0.16; 'foo,': 0.16; 'positional': 0.16; 'wrote:': 0.18; 'code.': 0.18; '(the': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'feature': 0.29; 'specified': 0.30; '>>>>': 0.31; 'spam,': 0.31; 'subject:what': 0.31; 'worked': 0.33; 'skip:_ 10': 0.34; 'subject:the': 0.34; 'could': 0.34; 'next': 0.36; 'charset:us- ascii': 0.36; 'example,': 0.37; 'two': 0.37; 'to:addr:python- list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'new': 0.61; 'received:173': 0.61; 'first': 0.61; 'name': 0.63; 'subject:self': 0.84 |
| Date | Wed, 13 Aug 2014 19:20:06 -0700 |
| From | Ethan Furman <ethan@stoneleaf.us> |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 |
| MIME-Version | 1.0 |
| To | python-list@python.org |
| Subject | Re: what is the "/" mean in __init__(self, /, *args, **kwargs) ? |
| References | <53EC1887.6060205@gmail.com> |
| In-Reply-To | <53EC1887.6060205@gmail.com> |
| Content-Type | text/plain; charset=us-ascii; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.12959.1407982808.18130.python-list@python.org> (permalink) |
| Lines | 24 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1407982808 news.xs4all.nl 2939 [2001:888:2000:d::a6]:55289 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:76250 |
Show key headers only | View raw
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~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: what is the "/" mean in __init__(self, /, *args, **kwargs) ? Ethan Furman <ethan@stoneleaf.us> - 2014-08-13 19:20 -0700
csiph-web