# determine how it ends up in the global symbol table. # # Sample output: # Property('S', 'HeLLo') Property('S', 'HeLLo') # 2 # 2 # 135099576 # 135033272 # 0 import metakit db = metakit.storage() v1 = db.getas('lo[HeLLo:S]') v2 = db.getas('hi[hello:S]') # surprise: this prints two mixed-case names print v1.HeLLo, v2.hello # this shows that the MetaKit property is the same for both # reason: there is a single global case-insensitive symbol table print metakit.property('S', 'HeLLo').id print metakit.property('S', 'hello').id # this shows that the Python objects differ # reason: these are two wrapper objects around the same thing print id(metakit.property('S', 'HeLLo')) print id(metakit.property('S', 'hello')) # this causes a mismatch, it will have to be fixed one day print metakit.property('S', 'HeLLo') == metakit.property('S', 'hello')
# determine how it ends up in the global symbol table. # # Sample output: # Property('S', 'HeLLo') Property('S', 'HeLLo') # 2 # 2 # 135099576 # 135033272 # 0 import metakit db = metakit.storage() v1 = db.getas('lo[HeLLo:S]') v2 = db.getas('hi[hello:S]') # surprise: this prints two mixed-case names print v1.HeLLo, v2.hello # this shows that the MetaKit property is the same for both # reason: there is a single global case-insensitive symbol table print metakit.property('S','HeLLo').id print metakit.property('S','hello').id # this shows that the Python objects differ # reason: these are two wrapper objects around the same thing print id(metakit.property('S','HeLLo')) print id(metakit.property('S','hello')) # this causes a mismatch, it will have to be fixed one day print metakit.property('S','HeLLo') == metakit.property('S','hello')
dd = [{ 'a': 'one', 'b': 'un', 'c': 1 }, { 'a': 'two', 'b': 'deux', 'c': 2 }, { 'a': 'three', 'b': 'trois', 'c': 3 }] dt = [('one', 'un', 1), ('two', 'deux', 2), ('three', 'trois', 3)] pl = [ metakit.property('S', 'a'), metakit.property('S', 'b'), metakit.property('I', 'c') ] vc = metakit.wrap(dc, pl) vd = metakit.wrap(dd, pl) vt = metakit.wrap(dt, pl, 1) metakit.dump(vc, 'class objects:') metakit.dump(vd, 'dictionary elements:') metakit.dump(vt, 'tuples (by position):')
import metakit class C: def __init__(self, a, b, c): self.a, self.b, self.c = a, b, c dc = [ C ('one', 'un', 1), C ('two', 'deux', 2), C ('three', 'trois', 3) ] dd = [ {'a':'one', 'b':'un', 'c':1}, {'a':'two', 'b':'deux', 'c':2}, {'a':'three', 'b':'trois', 'c':3} ] dt = [ ('one', 'un', 1), ('two', 'deux', 2), ('three', 'trois', 3) ] pl = [ metakit.property('S','a'), metakit.property('S','b'), metakit.property('I','c') ] vc = metakit.wrap(dc, pl) vd = metakit.wrap(dd, pl) vt = metakit.wrap(dt, pl, 1) metakit.dump(vc, 'class objects:') metakit.dump(vd, 'dictionary elements:') metakit.dump(vt, 'tuples (by position):')