How to list all functions in a Python module?

前端 未结 17 1969
野性不改
野性不改 2020-11-22 05:38

I have a python module installed on my system and I\'d like to be able to see what functions/classes/methods are available in it.

I want to call the doc function

17条回答
  •  一个人的身影
    2020-11-22 06:08

    Except dir(module) or help(module) mentioned in previous answers, you can also try:
    - Open ipython
    - import module_name
    - type module_name, press tab. It'll open a small window with listing all functions in the python module.
    It looks very neat.

    Here is snippet listing all functions of hashlib module

    (C:\Program Files\Anaconda2) C:\Users\lenovo>ipython
    Python 2.7.12 |Anaconda 4.2.0 (64-bit)| (default, Jun 29 2016, 11:07:13) [MSC v.1500 64 bit (AMD64)]
    Type "copyright", "credits" or "license" for more information.
    
    IPython 5.1.0 -- An enhanced Interactive Python.
    ?         -> Introduction and overview of IPython's features.
    %quickref -> Quick reference.
    help      -> Python's own help system.
    object?   -> Details about 'object', use 'object??' for extra details.
    
    In [1]: import hashlib
    
    In [2]: hashlib.
                 hashlib.algorithms            hashlib.new                   hashlib.sha256
                 hashlib.algorithms_available  hashlib.pbkdf2_hmac           hashlib.sha384
                 hashlib.algorithms_guaranteed hashlib.sha1                  hashlib.sha512
                 hashlib.md5                   hashlib.sha224
    

提交回复
热议问题