Skip to main content

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/estaleiroweb/mandrake

Instalation

pip install mandrake

Upgrade

pip install mandrake -upgrade

Use

from mandrake import AllMethods

class MyClass(AllMethods): ...
from mandrake 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

mandrake-0.0.2-py3-none-any.whl (5.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page