
Python has a ton of useful modules, and the built-in help facility is extremely useful for gaining quick access to a description of methods in a given module. Once a module is imported with import:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import pexpect |
You can run dir(MODULE_NAME) to view the list of methods in the module:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> dir(pexpect) | |
['EOF', 'ExceptionPexpect', 'TIMEOUT', '__all__', '__builtins__', '__doc__', '__file__', '__loader__', '__name__', '__revision__', '__version__', 'errno', 'fcntl', 'os', 'pty', 're', 'resource', 'run', 'searcher_re', 'searcher_string', 'select', 'signal', 'spawn', 'split_command_line', 'string', 'struct', 'sys', 'termios', 'time', 'traceback', 'tty', 'types', 'which'] |
To get help on a specific method, you can pass the module and method name to the built-in help function:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> help(pexpect.spawn) |
Help on class spawn in module pexpect:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class spawn(__builtin__.object) | |
| This is the main class interface for Pexpect. Use this class to start | |
| and control child applications. | |
| | |
| Methods defined here: | |
..... |
This is pretty sweet, and makes coding in Python super easy.
No comments:
Post a Comment