[PySide] The Signature Module for PySide2

Christian Tismer tismer at stackless.com
Sun Sep 24 05:55:27 CEST 2017


Bob, you are right. The __signature__ object is a true object for
introspection and you can directly use it to build a function
call programmatically or find default arguments. Not as strings
but as life objects.

I think that is a pretty unique feature. I know only of Cython
who creates signature objects from PyCFunctions. Therefore I expected
more enthusiastic reactions, the feature was very hard to implement.
And sure, the doc strings could be derived from it.

Probably I should have pointed people at PEP 362 ff.

Cheers -- Chris


On 23.09.17 04:49, Bob Hood wrote:
> I could be wrong, because I'm not familiar with the "__signature__"
> attribute, but I believe it is intended to facilitate /introspection/ of
> classes and methods.  When Christian said "prints", I think he just
> meant you get to see what the attribute holds, not that it should be
> used as documentation.
> 
> You could programmatically access the attributes data, and make run-time
> use of it.  You can't really do that with the help() output unless you
> want go to great lengths to parse it.
> 
> Sorry if I'm way off here.
> 
> 
> On 9/22/2017 8:36 PM, Zhao Lee wrote:
>> Sorry, I just feel the feature is just like what help() function do in
>> Python 
>> https://docs.python.org/3/library/functions.html#help
>>
>> an example with PyQt5
>> >>> from PyQt5.QtWidgets import QApplication
>> >>> help(QApplication.startTimer)
>> Help on built-in function startTimer:
>>
>> startTimer(...)
>>     startTimer(self, int, timerType: Qt.TimerType = Qt.CoarseTimer) -> int
>>
>> >>> 
>>
>>
>> 在2017年09月22 16时42分, "Christian Tismer"<tismer at stackless.com>写道:
>>
>>
>>     Hi,
>>
>>     please re-submit your reply in a readable way.
>>     I could read it locally, but the mailing list does not
>>     have a readable answer from you, just my copied text.
>>
>>     Can you please come up with more than just "why not?"?
>>     I need a proposal how the help should look like.
>>
>>     Thanks in advance -- Chris
>>
>>
>>     On 22.09.17 07:07, Zhao Lee wrote:
>>     > why not?
>>     >>>> help(PySide2.QtWidgets.QGraphicsAnchorLayout.addAnchors)
>>     >>>> help(PySide2.QtWidgets.QGraphicsAnchorLayout)
>>     >
>>     >
>>     >
>>     > 在2017年09月21 21时04分, "Christian Tismer"<tismer at stackless.com
>>     <mailto:tismer at stackless.com>>写道:
>>     >
>>     >
>>     >     Hi friends,
>>     >
>>     >     there is the new signature module for PySide2.
>>     >     It adds the __signature__ attribute to all PySide2
>>     >     functions and constructors.
>>     >
>>     >     Example usage:
>>     >
>>     >     >>>
>>     PySide2.QtWidgets.QGraphicsAnchorLayout.addAnchors.__signature__
>>     >     >>> PySide2.QtWidgets.QGraphicsAnchorLayout.__signature__
>>     >
>>     >     will print all annotations, defaults and return values.
>>     >
>>     >     The feature supports Python 2.7 and Python 3.4 and up.
>>     >     See further info at
>>     >
>>     >        https://bugreports.qt.io/browse/PYSIDE-510
>>     >
>>     >    
>>     https://github.com/pyside/pyside2-setup/blob/5.6/sources/shiboken2/libshiboken/signature.cpp
>>     >
>>     >    
>>     https://github.com/pyside/pyside2-setup/blob/5.6/sources/shiboken2/libshiboken/signature.cpp
>>     >
>>     >     Cheers -- Chris
>>     >
>>     >     --
>>     >     Christian Tismer             :^)   tismer at stackless.com
>>     <mailto:tismer at stackless.com>
>>     >     <mailto:tismer at stackless.com <mailto:tismer at stackless.com>>
>>     >     Software Consulting          :     http://www.stackless.com/
>>     >     Karl-Liebknecht-Str. 121     :     https://github.com/PySide
>>     >     14482 Potsdam                :     GPG key -> 0xFB7BEE0E
>>     >     phone +49 173 24 18 776  fax +49 (30) 700143-0023
>>     >
>>     >
>>     >
>>     >
>>     >
>>     >  
>>     >
>>
>>
>>     -- 
>>     Christian Tismer             :^)   tismer at stackless.com
>>     <mailto:tismer at stackless.com>
>>     Software Consulting          :     http://www.stackless.com/
>>     Karl-Liebknecht-Str. 121     :     https://github.com/PySide
>>     14482 Potsdam                :     GPG key -> 0xFB7BEE0E
>>     phone +49 173 24 18 776  fax +49 (30) 700143-0023
>>
>>
>>
>>  
>>
>>
>>
>> _______________________________________________ PySide mailing list
>> PySide at qt-project.org http://lists.qt-project.org/mailman/listinfo/pyside
> 
> 
> 
> _______________________________________________
> PySide mailing list
> PySide at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/pyside
> 


-- 
Christian Tismer             :^)   tismer at stackless.com
Software Consulting          :     http://www.stackless.com/
Karl-Liebknecht-Str. 121     :     https://github.com/PySide
14482 Potsdam                :     GPG key -> 0xFB7BEE0E
phone +49 173 24 18 776  fax +49 (30) 700143-0023

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 522 bytes
Desc: OpenPGP digital signature
URL: <http://lists.qt-project.org/pipermail/pyside/attachments/20170924/58e068b2/attachment.sig>


More information about the PySide mailing list