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.

schlichtanders.mymeta.Lift(cls)[source]

class decorator

schlichtanders.mymeta.LiftableFrom(base_cls_name)[source]
exception schlichtanders.mymeta.NotLiftable[source]

Bases: exceptions.TypeError

class schlichtanders.mymeta.Proxifier(subject, old_class, old_dict)[source]

Bases: object

Delegates 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.delift(self, base_class)[source]
schlichtanders.mymeta.get_subject(a)[source]

returns the final subject of possible several proxy layers

schlichtanders.mymeta.lift(self, new_class, **kwargs)[source]
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)

schlichtanders.mymeta.morph(instance1, instance2)[source]

makes instance1 to be instance2, however works inplace, i.e. preserves all references to instance1

schlichtanders.mymeta.mysuper(*args, **kwds)[source]
schlichtanders.mymeta.next_common_liftable_ancestor(classA, classB)[source]
schlichtanders.mymeta.proxify(a, b)[source]

makes a a proxy for b, in place

schlichtanders.mymeta.relift(self, new_class, base_class=None, **kwargs)[source]
schlichtanders.mymeta.super_liftable(*args, **kwds)[source]

this is kind of a hack to replace super.super, however I haven’t found any other nice way to do it