This is pretty simple, but it took me a few years before I ran into this. It’s just not covered in the basic documentation. Forget auto completion for a moment and let’s just show how to display the methods available for an object, any object.
>>> import subprocess
>>> p = subprocess.Popen(["cat file.conf"], shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
But I want to know what methods this object has without having to look it up…
>>> p.__dict__
{’_child_created’: True, ‘returncode’: None, ’stdout’:
>>> p.__dict__.keys()
['_child_created', 'returncode', 'stdout', 'stdin', 'pid', 'stderr', 'universal_newlines']
>>> import sys
>>> sys.__dict__.keys()
['setrecursionlimit', 'dont_write_bytecode', 'getrefcount', 'path_importer_cache', 'stdout', 'getprofile', '__stdin__', 'version_info', 'exc_clear', 'prefix', 'getfilesystemencoding', 'byteorder', '_clear_type_cache', 'excepthook', 'subversion', 'exc_type', 'ps1', '__excepthook__', 'executable', 'float_info', 'copyright', 'setdlopenflags', 'exec_prefix', 'getdlopenflags', 'getrecursionlimit', 'py3kwarning', 'path_hooks', '__package__', '_current_frames', 'platform', 'maxsize', 'version', 'exit', 'call_tracing', 'callstats', 'flags', 'setcheckinterval', '__doc__', 'api_version', '__plen', 'getdefaultencoding', 'getcheckinterval', 'maxunicode', 'settrace', 'setprofile', 'argv', '__stdout__', 'meta_path', '__name__', 'builtin_module_names', 'stdin', '__stderr__', '__egginsert', 'displayhook', 'ps2', 'gettrace', 'modules', 'warnoptions', 'last_type', 'getsizeof', 'last_traceback', 'maxint', '__displayhook__', '_getframe', 'stderr', 'exc_info', 'path', 'last_value', 'hexversion']
8:48 am
Thanks for the post - it took a few Google searches, but I finally found what I was looking for.