示例#1
0
 def __str__( me, **kargs):
     root = StaticType._stack is None
     if root: StaticType._stack = []
     r = make_str( me, me._order_Statics(), name_name='', **kargs)
         # name_name is by default 'name', which clashes easily.
         # it can be '_name_', but it is never used anyway:
         #  may only be used eventualy in Struct-class-vars which are instances
         #  of another Struct - but this will need meta-support
     if root: StaticType._stack = None
     return r
示例#2
0
        types = Descriptor4Container( Proxy4Container2)
        a = types.setdefault( 'a', int)
        b = types.setdefault( 'b', long)
        c = types.setdefault( 'c', float)
        def __init__( me):
            me.a = 1
            me.b = 2
            #me.c = 3
        def __str__( me):
            return make_str( me, me.types.iterkeys(), getattr= getattr_local_instance_only)

    q = Q()
    print 'inst.iteritems', list( q.types.iteritems())
    print 'klas.iteritems', list( Q.types.iteritems())
    print 'inst.itertypes', list( q.types.itertypes())
    print 'inst:', q
    print 'klas:', make_str( Q, Q.types.iterkeys(), name_name='__name__')

    print 'indexing:', q.types, '["a"] =', q.types['a']

    keys = q.types.keys
    print 'keys - from parent', keys, keys()

    try:
        q.types['a'] = 1
    except TypeError: pass
    else: assert not 'types must not allow item assignment'


# vim:ts=4:sw=4:expandtab
示例#3
0
 def __str__( me):
     return make_str( me, me.types.iterkeys(), getattr= getattr_local_instance_only)
示例#4
0
 def __str__( me, order =None):
     return _str.make_str( me, me.StaticType.iterkeys( order), name_name='' )