Skip to content

Instantly share code, notes, and snippets.

View blackhathedgehog's full-sized avatar

blackhathedgehog

View GitHub Profile
@blackhathedgehog
blackhathedgehog / monkeypatch.py
Created October 31, 2017 23:09
Quick Monkeypatch example of the 0.3.0 to allow Literal Value to be directly mathematically operated on
from python_jsonschema_objects.classbuilder import LiteralValue
# int and float are already implemented, and thus not shown here
LiteralValue.__getattr__ = lambda self, name: getattr(self._value, name)
LiteralValue.__add__ = lambda self, other: self._value + other
LiteralValue.__sub__ = lambda self, other: self._value - other
LiteralValue.__mul__ = lambda self, other: self._value * other
LiteralValue.__matmul__ = lambda self, other: self._value @ other