Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
python3.4 On 8/14/2014 10:12 AM, Tim Chase wrote: On 2014-08-14 10:01, 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) ? Where are you seeing this? Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. help(int.__init__) Help on wrapper_descriptor: __init__(...) x.__init__(...) initializes x; see help(type(x)) for signature ^D Python 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. help(int.__init__) Help on wrapper_descriptor: __init__(...) x.__init__(...) initializes x; see help(type(x)) for signature -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
On 14/08/2014 03:08, Ben Finney wrote: luofeiyu elearn2...@gmail.com writes: 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) ? I don't know, I haven't seen that before. It is confusing. At least it is acknowledged (“See [elsewhere] for accurate signature”) to be unhelpful. I suspect this is an artefact of the impedance mismatch between Python function signatures and the implementation of ‘int’ in C code. The “/” may be a placeholder for something the C implementation requires but that Python's function signature expectation doesn't allow. Perhaps Python 3's keyword-only arguments may one day help functions like that get implemented with a more useful signature, but I'm not holding my breath for that. Something to do with the Argement Clinic http://legacy.python.org/dev/peps/pep-0436/ ??? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
what is the / mean in __init__(self, /, *args, **kwargs) ?
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) ? -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
luofeiyu elearn2...@gmail.com writes: 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) ? I don't know, I haven't seen that before. It is confusing. At least it is acknowledged (“See [elsewhere] for accurate signature”) to be unhelpful. I suspect this is an artefact of the impedance mismatch between Python function signatures and the implementation of ‘int’ in C code. The “/” may be a placeholder for something the C implementation requires but that Python's function signature expectation doesn't allow. Perhaps Python 3's keyword-only arguments may one day help functions like that get implemented with a more useful signature, but I'm not holding my breath for that. -- \ “Religious faith is the one species of human ignorance that | `\ will not admit of even the *possibility* of correction.” —Sam | _o__) Harris, _The End of Faith_, 2004 | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
On 2014-08-14 10:01, 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) ? Where are you seeing this? Python 2.7.3 (default, Mar 13 2014, 11:03:55) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. help(int.__init__) Help on wrapper_descriptor: __init__(...) x.__init__(...) initializes x; see help(type(x)) for signature ^D Python 3.2.3 (default, Feb 20 2013, 14:44:27) [GCC 4.7.2] on linux2 Type help, copyright, credits or license for more information. help(int.__init__) Help on wrapper_descriptor: __init__(...) x.__init__(...) initializes x; see help(type(x)) for signature -tkc -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
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~ -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
On 08/13/2014 07:12 PM, Tim Chase wrote: Where are you seeing this? Probably in 3.4, or the tip (what will be 3.5). -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
Tim Chase python.l...@tim.thechases.com writes: On 2014-08-14 10:01, 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) ? Where are you seeing this? I see the same output as ‘luofeiyu’ reports. My Python is:: sys.version '3.4.1 (default, Jul 26 2014, 13:46:45) \n[GCC 4.9.1]' -- \“Stop — Drive sideways.” —detour sign, Kyushu, Japan | `\ | _o__) | Ben Finney -- https://mail.python.org/mailman/listinfo/python-list
Re: what is the / mean in __init__(self, /, *args, **kwargs) ?
On 8/13/2014 10:20 PM, Ethan Furman wrote: 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. In particular, int.__init__(self = subclass instance) will not work because 'self' is positional only. (I don't think int.__init__ actually does anything, but a subclass of int might call it.) 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). I hope / will be valid Python in 3.5. -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list