0 votes
in Python Flask by
Explain help() and dir() functions in Python.

1 Answer

0 votes
by
The help() function displays the documentation string and help for its argument.

>>> import copy
>>> help(copy.copy)
Help on function copy in module copy:

copy(x)

Shallow copy operation on arbitrary Python objects.

See the module’s __doc__ string for more info.

The dir() function displays all the members of an object(any kind).

>>> dir(copy.copy)
[‘__annotations__’, ‘__call__’, ‘__class__’, ‘__closure__’, ‘__code__’, ‘__defaults__’, ‘__delattr__’, ‘__dict__’, ‘__dir__’, ‘__doc__’, ‘__eq__’, ‘__format__’, ‘__ge__’, ‘__get__’, ‘__getattribute__’, ‘__globals__’, ‘__gt__’, ‘__hash__’, ‘__init__’, ‘__init_subclass__’, ‘__kwdefaults__’, ‘__le__’, ‘__lt__’, ‘__module__’, ‘__name__’, ‘__ne__’, ‘__new__’, ‘__qualname__’, ‘__reduce__’, ‘__reduce_ex__’, ‘__repr__’, ‘__setattr__’, ‘__sizeof__’, ‘__str__’, ‘__subclasshook__’]
...