schlichtanders.mymeta module¶
This is one of my favourite packages - collecting meta implementations.
Most useful is probably proxify, ok, it is impressively useful here and there. But also take a look at the lift
utilities, however, they may be validly replaced with myfunctools.convert.
Enjoy.
-
class
schlichtanders.mymeta.Proxifier(subject, old_class, old_dict)[source]¶ Bases:
objectDelegates all operations (except
.__subject__, .__original__) to another object__original__returns a new instance of the originally proxified object
-
schlichtanders.mymeta.clcoancl(*cls_list)[source]¶ read as closest common ancestor class taken from: http://stackoverflow.com/questions/15788725/how-to-determine-the-closest-common-ancestor-class
-
schlichtanders.mymeta.get_subject(a)[source]¶ returns the final subject of possible several proxy layers
-
schlichtanders.mymeta.lift_from(*classes)[source]¶ shall decorate class method ideally >>> class A(object): ... pass ... >>> class B(A): ... @lift_from(A) ... @staticmethod ... def lift(a,_b): ... a.__class__ = B ... a._b = _b ... >>> class C(B): ... def __init__(self, _c): ... self._c = _c ... ... @lift_from(B) ... @staticmethod ... def lift(b, _c): ... b.__class__ = C ... b._c = _c ... ... def __str__(self): ... return “%s(_b=%s,_c=%s)” % (self.__class__.__name__, self._b, self._c) ... >>> a = A() >>> C.lift(a, _b=”b”, _c=”c”) >>> print a C(_b=b,_c=c)