Basic module question:

Joel Ricker joejava at dragonat.net
Sun Jan 7 22:12:51 EST 2001


Stanton Schell wrote in message ...
>I am learning Python and I am trying to find out all the functions I have
>available to me within sys.stdin (eg read(), readlines(), etc...).  I
>realize this brings up a more fundamental question for me: how do I find
out
>what is available in any module (which I guess would then apply to other
>objects written by other people...)?
>
>any help or resource guidance would greatly appreciated :-)


Other than the module's documentation, the other thing you could do is use
dir() like this:

>>> import time
>>> dir(time)
['__doc__', '__name__', 'accept2dyear', 'altzone', 'asctime', 'clock',
'ctime',
'daylight', 'gmtime', 'localtime', 'mktime', 'sleep', 'strftime', 'time',
'timez
one', 'tzname']
>>>

dir() will also give you a list of functions and variables defined in the
current namespace.

dir() won't give you a list of builtin functions though.  To get those, use
the __builtin__ module:

>>> import __builtin__
>>> dir(__builtin__)
[*snip -- Long list of builtin functions/variables*]

Hope that helps

Joel "Just started learning python himself" Ricker

I have been Perl-Free for 3 Days, 0 Hours, 23 Minutes, and 14 Seconds.
------------------------------------------------------------
Joel Ricker   joejava at dragoncat.net
  Just Another Python Hacker





More information about the Python-list mailing list