And now for something completely boneheaded...
Philip Lijnzaad
lijnzaad at ebi.ac.uk
Wed Sep 8 05:20:25 EDT 1999
> So with a given module, once imported, what is the way by which I can find
> out what's defined in the module
Number of ways ... first of all, of course, RTFM.
Next, print the doc string. Incidentally, many objects (including functions
such as dir, see below) have this __doc__ string:
>>> print sys.__doc__
Next, use the dir function, which prints the 'attributes' of the object. For a
module, attributes means the names defined in the module:
>>> dir(sys)
Next, each scope is represented by a dictionary which is available under its
__dict__ attribute, so you can print that too
>>> print sys.__dict__
And to make this more readable, try
>>> for i in sys.__dict__.keys(): print i,":", sys.__dict__[i]
And I'm sure there are other ways.
> and, ideally, how to access it?
why,
module.name for referring to things
module.name[] for indexing into things
module.name() for calling things
Cheers,
Philip
--
The cause of the millenium bug is Homo Sapiens having 10 fingers
-----------------------------------------------------------------------------
Philip Lijnzaad, lijnzaad at ebi.ac.uk | European Bioinformatics Institute,rm A2-24
+44 (0)1223 49 4639 | Wellcome Trust Genome Campus, Hinxton
+44 (0)1223 49 4468 (fax) | Cambridgeshire CB10 1SD, GREAT BRITAIN
PGP fingerprint: E1 03 BF 80 94 61 B6 FC 50 3D 1F 64 40 75 FB 53
More information about the Python-list
mailing list