Python Func Dir
# Python2.x Python dir() Function
[ Python Built-in Functions](#)
* * *
## Description
The **dir()** function, when called without arguments, returns a list of variables, methods, and defined types in the current scope; when called with an argument, it returns a list of attributes and methods of the argument. If the argument contains the method `__dir__()`, this method will be called. If the argument does not contain `__dir__()`, the method will collect information about the argument to the maximum extent possible.
## Syntax
dir syntax:
dir()
Parameter Description:
* object -- An object, variable, or type.
## Return Value
Returns a list of attributes of the module.
## Examples
The following examples demonstrate the usage of dir:
>>>dir()# Get the list of attributes of the current module[' __builtins__ ', ' __doc__ ', ' __name__ ', ' __package__ ', 'arr', 'myslice']>>>dir([])# View the methods of a list[' __add__ ', ' __class__ ', ' __contains__ ', ' __delattr__ ', ' __delitem__ ', ' __delslice__ ', ' __doc__ ', ' __eq__ ', ' __format__ ', ' __ge__ ', ' __getattribute__ ', ' __getitem__ ', ' __getslice__ ', ' __gt__ ', ' __hash__ ', ' __iadd__ ', ' __imul__ ', ' __init__ ', ' __iter__ ', ' __le__ ', ' __len__ ', ' __lt__ ', ' __mul__ ', ' __ne__ ', ' __new__ ', ' __reduce__ ', ' __reduce_ex__ ', ' __repr__ ', ' __reversed__ ', ' __rmul__ ', ' __setattr__ ', ' __setitem__ ', ' __setslice__ ', ' __sizeof__ ', ' __str__ ', ' __subclasshook__ ', 'append', 'count', 'extend', 'index', 'insert', 'pop', 'remove', 'reverse', 'sort']>>>
[ Python Built-in Functions](#)
YouTip