Feat: overload pow for tokens
This commit is contained in:
parent
2a74722b19
commit
84c71f6b5d
@ -238,6 +238,28 @@ class Token(object):
|
|||||||
"""
|
"""
|
||||||
return self._operate(other, "/")
|
return self._operate(other, "/")
|
||||||
|
|
||||||
|
def __pow__(self, other):
|
||||||
|
""" Token powered by an other
|
||||||
|
|
||||||
|
:example:
|
||||||
|
>>> from .number import Integer
|
||||||
|
>>> a = Integer(3)
|
||||||
|
>>> b = Integer(7)
|
||||||
|
>>> c = a ** b
|
||||||
|
>>> c
|
||||||
|
<Integer 2187>
|
||||||
|
>>> c = a ** 7
|
||||||
|
>>> c
|
||||||
|
<Integer 2187>
|
||||||
|
>>> from .number import Decimal
|
||||||
|
>>> a = Decimal('2.3')
|
||||||
|
>>> c = a ** 2
|
||||||
|
>>> c
|
||||||
|
<Decimal 5.29>
|
||||||
|
|
||||||
|
"""
|
||||||
|
return self._operate(other, "^")
|
||||||
|
|
||||||
|
|
||||||
def _roperate(self, other, operation):
|
def _roperate(self, other, operation):
|
||||||
""" Make a operation between 2 Tokens """
|
""" Make a operation between 2 Tokens """
|
||||||
|
Loading…
Reference in New Issue
Block a user