I created my first pypi package.
Was working on a modified version of dir
, and decided to make a package.
This is how to use it,
pip install enhanced_dir
from enhanced_dir import enhanced_dir
enhanced_dir(list(), categorize=True, show_types=True, checks=True, collections_abc_list=True)
(have four keyword arguments)
categorize - it would display the class name of the method
show_types - it would show the type of the method
checks - certain checks, such as could the argument be a key to a dictionary, is it iterable, inheritable
collections_abc_list - would give the list of interfaces in the collections.abc module that are implemented by the argument
so, for the above example,
specifying categorize=True
gives,
[{'passed': defaultdict(<function enhanced_dir.<locals>.<lambda> at 0x7fb4e2096b90>,
{'[]': defaultdict(<class 'set'>,
{'list': {'__add__', '__contains__', '__delitem__', '__dir__', '__eq__',
'__format__', '__ge__', '__getattribute__', '__getitem__',
'__gt__', '__iadd__', '__imul__', '__init__', '__init_subclass__',
'__iter__', '__le__', '__len__', '__lt__', '__mul__', '__ne__',
'__new__', '__reduce__', '__reduce_ex__', '__repr__',
'__reversed__', '__rmul__', '__setitem__', '__sizeof__',
'__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend',
'index', 'insert', 'pop', 'remove', 'reverse', 'sort'},
'object': {'__str__', '__setattr__', '__delattr__'}})})},
{'failed': defaultdict(<class 'set'>, {'[]': {'__doc__', '__hash__', '__class__'}})}
specifying show_types=True
gives,
{'passed_types': defaultdict(<function enhanced_dir.<locals>.<lambda> at 0x7fb4e2096dd0>,
{'[]': defaultdict(<class 'set'>,
{<class 'method-wrapper'>: {'__add__', '__contains__', '__delattr__',
'__delitem__', '__eq__', '__ge__',
'__getattribute__', '__gt__', '__iadd__',
'__imul__', '__init__', '__iter__',
'__le__', '__len__', '__lt__', '__mul__',
'__ne__', '__repr__', '__rmul__',
'__setattr__', '__setitem__', '__str__'},
<class 'builtin_function_or_method'>: {'__dir__', '__format__',
'__getitem__',
'__init_subclass__', '__new__',
'__reduce__', '__reduce_ex__',
'__reversed__', '__sizeof__',
'__subclasshook__', 'append',
'clear', 'copy', 'count',
'extend', 'index', 'insert',
'pop', 'remove', 'reverse',
'sort'}})})},
{'failed_types': defaultdict(<function enhanced_dir.<locals>.<lambda> at 0x7fb4e20e03b0>,
{'[]': defaultdict(<class 'set'>,
{<class 'type'>: {'__class__'},
<class 'NoneType'>: {'__hash__'},
<class 'str'>: {'__doc__'}})})}
specifying collections_abc_list=True
gives,
[{'Collection', 'Sequence', 'Iterable', 'Reversible', 'Sized', 'MutableSequence', 'Container'}]
specifying checks=True
gives,
[{'defaultdict_arg': False, 'dict_key': False, 'inheritable': False, 'iterable': True}]]
(I used from pprint import pprint
to print the output)
Is there something I could change here, either add or remove or modify a functionality?