----- Original Message ----- From: "Kevin Jacobs" <jacobs@penguin.theopalgroup.com> > Second, I've been twisting metaclasses to do my evil bidding. Fun, innit? > In this case, > I have implemented pseudo-typed attributes and slots in Python. e.g.: > > class A(object): > __metaclass__ = ConstrainedObject > __slots__ = {'a':int,'b':float} Although I understand the appeal, using __slots__ to constrain the attributes might be misguided (depending on your goals): >>> class A(object): ... __slots__ = [ 'a' ] ... >>> class B(object): ... __slots__ = [ 'b' ] ... >>> class C(A,B): pass ... Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: multiple bases have instance lay-out conflict >>> class D(object): pass ... >>> class C(A,D): pass ... >>>
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4