list/get methods/attributes of a class?

B

bkamrani

Hello,
Sorry guys for this newbie questions. But I wonder if there is a
standard or build-in method to know the methods of a class?

I'm not originally a progrommer and I have worked with python/qt in a
basic level. Now I work a package which has many predefined classes
which I'm going to resue by importing them. I would like to know more
about each imported class, what methods exists and so on. Printing the
object or type(object) doesn't say so much.

Any hint or helps is really appreciated!
/Ben
 
J

Jason

Hello,
Sorry guys for this newbie questions. But I wonder if there is a
standard or build-in method to know the methods of a class?

I'm not originally a progrommer and I have worked with python/qt in a
basic level. Now I work a package which has many predefined classes
which I'm going to resue by importing them. I would like to know more
about each imported class, what methods exists and so on. Printing the
object or type(object) doesn't say so much.

Any hint or helps is really appreciated!
/Ben

Also, try out the built-in help function on the original class. It'll
list the class layout, methods, and any associated document strings.
(It won't list member variables, though.) To see all elements in an
instance or class, use the dir() function.
.... "A sample class that can have any given data."
.... def __init__(self, *args):
.... self._args = args
.... def GetArgCount(self):
.... """Show how many arguments were passed at
instantiation."""
.... return len(self._args)
....Help on Dummy in module __main__ object:

class Dummy(__builtin__.object)
| A sample class that can have any given data.
|
| Methods defined here:
|
| GetArgCount(self)
| Show how many arguments were passed at instantiation.
|
| __init__(self, *args)
|
|
----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __dict__ = <dictproxy object>
| dictionary for instance variables (if defined)
|

--Jason
 
B

bkamrani

Also, try out the built-in help function on the original class. It'll
list the class layout, methods, and any associated document strings.
(It won't list member variables, though.) To see all elements in an
instance or class, use the dir() function.


... "A sample class that can have any given data."
... def __init__(self, *args):
... self._args = args
... def GetArgCount(self):
... """Show how many arguments were passed at
instantiation."""
... return len(self._args)
...>>> d = Dummy(1, 2, 'three')

Help on Dummy in module __main__ object:

class Dummy(__builtin__.object)
| A sample class that can have any given data.
|
| Methods defined here:
|
| GetArgCount(self)
| Show how many arguments were passed at instantiation.
|
| __init__(self, *args)
|
|
----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __dict__ = <dictproxy object>
| dictionary for instance variables (if defined)
|
| __weakref__ = <attribute '__weakref__' of 'Dummy' objects>
| list of weak references to the object (if defined)



--Jason

Thanks and regards!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top