BeAllAround / BeAllAround/py_utils
credentials for the deepEqual python-native __utils library extension
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
```
# deepEqual - dicts
def __eq__(obj, _obj):
if type(obj) != type(_obj):
return False
if type(obj) == dict and type(_obj) == dict:
if len(obj.keys()) != len(_obj.keys()):
return False
for key in obj.keys():
if key not in _obj.keys():
return False
if(not __eq__(obj[key], _obj[key])):
return False
return True
else:
return obj == _obj
# tests
print('# test 1: ', __eq__({'a': 1, 'b': 2,}, {'a': 1, 'b': 2,}))
print('# test 2: ', __eq__({'a': 1, 'b': {'a': 7},}, {'a': 1, 'b': {'a': 7},}))
obj = {'a': 1,}
obj['b'] = obj
# (built-in __eq__) how does it work - does it match the pointer address?
print('# py-test 3: ', obj == obj)
print('# py-test 3: ', obj['b'] == obj)
# Recursion Error: maximum recursion
# print('# test 3: ', __eq__(obj, obj))
# print('# test 3: ', __eq__(obj['b'], obj))
```
Helper: https://stackoverflow.com/a/63310298/14102601
Live repl example:

Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.