All Magic Methods Implement. You can easyly to implement all magic methods or part of them
Project description
Description
Version: 0.0.1 python 2.x,3.x
All Magic Methods Implement.
You can easyly to implement all magic methods or part of them
Donate
PIX: +55 31 99101-8619
Contact
URL: http://estaleiroweb.com.br
GIT: https://github.com/HelbertFernandes/magic_methods
Instalation
pip install magic_methods
Upgrade
pip install magic_methods -upgrade
Use
from magicmethods import AllMethods
class MyClass(AllMethods): ...
from magicmethods import AttributeMethods
class MyClass(AttributeMethods):
def __init__(self):
super().__init__()
self._start_init()
self.attr1 = 1
self._end_init()
def _set_value(self,val):
self.__dict__['value']=val * 2
def _set_attr2(self,val):
self.__dict__['attr2']=val * 3
c = MyClass()
c.value = 2
c.attr1 = 2
c.attr2 = 2
c.attr3 = 2
print({'value': {'check': hasattr(c, 'value'), 'val': c.value}})
print({'attr1': {'check': hasattr(c, 'attr1'), 'val': c.attr1}})
print({'attr2': {'check': hasattr(c, 'attr2'), 'val': c.attr2}})
print({'attr3': {'check': hasattr(c, 'attr3')}})
'''Response:
{'value': {'check': True, 'val': 4}}
{'attr1': {'check': True, 'val': 2}}
{'attr2': {'check': True, 'val': 6}}
{'attr3': {'check': False}}
'''
MainMethods
Any classes bellow will inherit this class.
It implement then __init__
method this value
attribute.
The children classes must be the methods _start_init()
and _end_init()
to define attributes of class or if wish, you can not use _end_init()
permiting add any attribute to this object
MathMethods
Implement all Math magic methods
FunctionMethods
Implement all Function magic methods
LogicMethods
Implement all Logic magic methods
BinaryMethods
Implement all Binary magic methods
StringMethods
Implement all String magic methods
CastMethods
Implement all Cast magic methods
AttributeMethods
You can creating _set_<attr>
methods to assure the correct value
AllMethods
The same all classes above
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file mandrake-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: mandrake-0.0.1-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68d6da54da12b039e2cda706ca26276327e8d136d56960ec6de5fcefe509bf5b |
|
MD5 | 88a4ca971c05622def1b07fd8e980f36 |
|
BLAKE2b-256 | def7a36614b2040de8e65f0344da5597ee0b5ecdfde5f916e5ad385be6c9623e |