9.4 View module content
dir (): returns all of the program modules or unit class contains (including variables, functions, classes and methods)
__all__: variable module itself provides, the program will not show units begin with an underscore. Another use from xx import *, is not introduced into the program begins with an underscore unit
import logging, pprint pprint.pprint ( dir (logging)) [ ' BASIC_FORMAT ' , ' BufferingFormatter ' , ' Critical ' , ' debug ' , ' ERROR ' , ' deadly ' , ' FileHandler ' , ' Filter ' , ' Filterer ' , ' Formatter ' , ' Handler ' , 'INFO', 'LogRecord', 'Logger', 'LoggerAdapter', 'Manager', 'NOTSET', 'NullHandler', 'PercentStyle', 'PlaceHolder', 'RootLogger', 'StrFormatStyle', 'StreamHandler', 'StringTemplateStyle', 'Template', 'WARN', 'WARNING', '_STYLES', '_StderrHandler', '__all__', '__author__', '__builtins__', '__cached__', '__date__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', '__status__', '__version__', '_acquireLock', '_addHandlerRef', '_checkLevel', '_defaultFormatter', '_defaultLastResort', '_handlerList', '_handlers', '_levelToName', '_lock', '_logRecordFactory', '_loggerClass', '_nameToLevel', '_releaseLock', '_removeHandlerRef', '_showwarning', '_srcfile', '_startTime', '_warnings_showwarning', 'addLevelName', 'atexit', 'basicConfig', 'captureWarnings', 'collections', 'critical', 'currentframe', 'debug', 'disable', 'error', 'exception', 'fatal', 'getLevelName', 'getLogRecordFactory ' , ' getLogger ' , ' getLoggerClass ' , ' info ' , ' I ' , ' LastResort ' , ' log ' , ' logMultiprocessing ' , ' logProcesses ' , ' logThreads ' , ' makeLogRecord ' , ' os ' , 'raiseExceptions', 'root', 'setLogRecordFactory', 'setLoggerClass', 'shutdown', 'sys', 'threading', 'time', 'traceback', 'warn', 'warning', 'warnings', 'weakref'] pprint.pprint(logging.__all__) ['BASIC_FORMAT', 'BufferingFormatter', 'CRITICAL', 'DEBUG', 'ERROR', 'FATAL', 'FileHandler', 'Filter', 'Formatter', 'Handler', 'INFO', 'LogRecord', 'Logger', 'LoggerAdapter', 'NOTSET', 'NullHandler', 'StreamHandler', 'WARN', 'WARNING', 'addLevelName', 'basicConfig', 'captureWarnings', 'critical', 'debug', 'disable', 'error', 'exception', 'fatal', 'getLevelName', 'getLogger', 'getLoggerClass', 'info', 'log', 'makeLogRecord', 'setLoggerClass', 'shutdown', 'warn', 'warning', 'getLogRecordFactory', ' SetLogRecordFactory ' , ' LastResort ' , ' raiseExceptions ' ]
Use __doc__ property to view the document. Another: Use help () function to see the property value is actually __doc__ program unit
import string help(string.capwords) Help on function capwords in module string: capwords(s, sep=None) capwords(s [,sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed, otherwise sep is used to split and join the words. print(string.capwords.__doc__) capwords(s [,sep]) -> string Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. If the optional second argument sep is absent or None, runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed, otherwise sep is used to split and join the words.
Use __file__ View the properties of the source module file path
import string string.__file__ 'E:\\soft\\Python\\Python36\\lib\\string.py'