[Python-Dev] undocumented help() function change in Python 3.4?
Jurko Gospodnetić
jurko.gospodnetic at pke.hr
Fri Mar 7 21:10:54 CET 2014
More information about the Python-Dev mailing list
Fri Mar 7 21:10:54 CET 2014
- Previous message: [Python-Dev] Relaxáló masszázs otthon.
- Next message: [Python-Dev] undocumented help() function change in Python 3.4?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi. I just noticed that the way help() function displays a function signature changed between Python 3.3 & 3.4 but I can not find this documented anywhere. Here's a matching example in both Python 3.3 & Python 3.4 for comparison: ---------------------------------------- > Python 3.3.3 (v3.3.3:c3896275c0f6, Nov 18 2013, 21:19:30) [MSC v.1600 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> def f(a, b, c): > ... print(a, b, c) > ... >>>> def g(*args, **kwargs): > ... f(*args, **kwargs) > ... >>>> import inspect >>>> print(inspect.signature(f)) > (a, b, c) >>>> print(inspect.signature(g)) > (*args, **kwargs) >>>> g.__wrapped__ = f >>>> print(inspect.signature(f)) > (a, b, c) >>>> print(inspect.signature(g)) > (a, b, c) >>>> help(f) > Help on function f in module __main__: > > f(a, b, c) > >>>> help(g) > Help on function g in module __main__: > > g(*args, **kwargs) ---------------------------------------- > Python 3.4.0b3 (v3.4.0b3:a97ce3ecc96a, Jan 26 2014, 17:50:55) [MSC v.1600 64 bit (AMD64)] on win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> def f(a, b, c): > ... print(a, b, c) > ... >>>> def g(*args, **kwargs): > ... f(*args, **kwargs) > ... >>>> import inspect >>>> print(inspect.signature(f)) > (a, b, c) >>>> print(inspect.signature(g)) > (*args, **kwargs) >>>> g.__wrapped__ = f >>>> print(inspect.signature(f)) > (a, b, c) >>>> print(inspect.signature(g)) > (a, b, c) >>>> help(f) > Help on function f in module __main__: > > f(a, b, c) > >>>> help(g) > Help on function g in module __main__: > > g(a, b, c) ---------------------------------------- As you can see by comparing those two outputs, setting the __wrapped__ attribute on a wrapper function affects the inspect.signature() results on that function. This behaviour is the same in both Python 3.3. & 3.4 and is (somewhat) described in the Python documentation. However, help() output is not affected by this in Python 3.3, but is affected in Python 3.4, and I can not find anything regarding this in the Python 3.4 docs. Can something related to this be added at least to the 'what's changed' docs, if not to the help() documentation as well? Best regards, Jurko Gospodentić
- Previous message: [Python-Dev] Relaxáló masszázs otthon.
- Next message: [Python-Dev] undocumented help() function change in Python 3.4?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list