mccartnm / purepy Goto Github PK
View Code? Open in Web Editor NEWPure Virtual Utility for Python
License: MIT License
Pure Virtual Utility for Python
License: MIT License
Because getattr()
will follow through with the get
on a property, we can have objects in a bad state.
from purepy import PureVirtualMeta, pure_virtual
class Foo(metaclass=PureVirtualMeta):
def __init__(self):
self._thing = 10
@property
def get_thing_math(self):
return self.some_func(self._thing)
@pure_virtual
def some_func(self):
raise NotImplementedError()
def overload_me_to_not_pv(self, thing):
raise NotImplementedError()
class Bar(Foo):
def some_func(self, thing):
self.overload_me_to_not_pv(thing)
# We don't have to overload overload_me_to_not_pv(), but when we make a Bar() object:
b = Bar()
# ...
# File "C:\virtualenv\pgfun\lib\site-packages\purepy\__init__.py", line 80, in __call__
# functions = PureVirtualMeta.pure_virtual_functions(inst)
# File "C:\virtualenv\pgfun\lib\site-packages\purepy\__init__.py", line 154, in pure_virtual_functions
# for name, call in inspect.getmembers(instance, predicate=PureVirtualMeta._predicate):
# File "C:\Users\Michael McCartney\AppData\Local\Programs\Python\Python37\lib\inspect.py", line 341, in getmembers
# value = getattr(object, key)
...
# raise NotImplementedError()
This is wrong because we don't want to evaluate the property
. We just want to find the virtual functions. May have to rethink the design slightly
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.