简体   繁体   中英

How to get help of PyGTK methods?

in pygtk when I set the label mylabel = gtk.Label("Hello World!") I can get the string of label from it by mylabel.get() method. but in python interpreter I can't get the docstring of this method: help(gtk.Label.get) . Anyone know why?

Because the method gtk.Label.get is an object itself, and has some attributes. The builtin function help looks the __doc__ attribute and some other dictionaries of the object and the Class of the object up and returns them (formatted). You could do a help(help) for example! ;-) so help(gtk.Label.get) returns the attribute " __doc__ " of the method/object gtk.Label.get and some other information gathered by class-introspection. It doesn't give you a help on the actual values of your gtk.Label instance .

I recommend you to use ipython's dynamic object information is quite helpful when playing with some library in the interpreter or when debugging some code.

Aside from that, if you're using linux, installing the pygtk documentation package is also very helpful because it integrates nicely with devhelp , a tool that lets you browse and search the documentation easily.

It might be that what you wanted to ask was answered by @DonQuestion already... however if you truly just wanted to ask why help(gtk.Label.get) doesn't return a help... the answer is actually very simple: because the get method in the Label object lacks a docstring in the source code. :)

In fact the call to help doesn't generate an error, just an empty answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM