All Samples(113125) | Call(111014) | Derive(2085) | Import(26)
type(object) -> the object's type type(name, bases, dict) -> a new type
src/m/a/matplotlib-HEAD/matplotlib/examples/units/basic_units.py matplotlib(Download)
class TaggedValueMeta (type):
def __init__(cls, name, bases, dict):
for fn_name in cls._proxies.keys():
try:
dummy = getattr(cls, fn_name)
except AttributeError:
setattr(cls, fn_name, ProxyDelegate(fn_name, cls._proxies[fn_name]))
def __call__(self, *args):
ret = PassThroughProxy.__call__(self, *args)
if (type(ret) == type(NotImplemented)):
return NotImplemented
return TaggedValue(ret, self.unit)
class ConvertAllProxy(PassThroughProxy):
arg_units.append(None)
converted_args = tuple(converted_args)
ret = PassThroughProxy.__call__(self, *converted_args)
if (type(ret) == type(NotImplemented)):
return NotImplemented
ret_unit = unit_resolver(self.fn_name, arg_units)
if (ret_unit == NotImplemented):
def __new__(cls, value, unit):
# generate a new subclass for value
value_class = type(value)
try:
subcls = type('TaggedValue_of_%s' % (value_class.__name__),
tuple([cls, value_class]),
{})
src/m/a/matplotlib-HEAD/examples/units/basic_units.py matplotlib(Download)
class TaggedValueMeta (type):
def __init__(cls, name, bases, dict):
for fn_name in cls._proxies.keys():
try:
dummy = getattr(cls, fn_name)
except AttributeError:
setattr(cls, fn_name, ProxyDelegate(fn_name, cls._proxies[fn_name]))
def __call__(self, *args):
ret = PassThroughProxy.__call__(self, *args)
if (type(ret) == type(NotImplemented)):
return NotImplemented
return TaggedValue(ret, self.unit)
class ConvertAllProxy(PassThroughProxy):
arg_units.append(None)
converted_args = tuple(converted_args)
ret = PassThroughProxy.__call__(self, *converted_args)
if (type(ret) == type(NotImplemented)):
return NotImplemented
ret_unit = unit_resolver(self.fn_name, arg_units)
if (ret_unit == NotImplemented):
def __new__(cls, value, unit):
# generate a new subclass for value
value_class = type(value)
try:
subcls = type('TaggedValue_of_%s' % (value_class.__name__),
tuple([cls, value_class]),
{})
src/m/a/Matplotlib--JJ-s-dev-HEAD/examples/units/basic_units.py Matplotlib--JJ-s-dev(Download)
class TaggedValueMeta (type):
def __init__(cls, name, bases, dict):
for fn_name in cls._proxies.keys():
try:
dummy = getattr(cls, fn_name)
except AttributeError:
setattr(cls, fn_name, ProxyDelegate(fn_name, cls._proxies[fn_name]))
def __call__(self, *args):
ret = PassThroughProxy.__call__(self, *args)
if (type(ret) == type(NotImplemented)):
return NotImplemented
return TaggedValue(ret, self.unit)
class ConvertAllProxy(PassThroughProxy):
arg_units.append(None)
converted_args = tuple(converted_args)
ret = PassThroughProxy.__call__(self, *converted_args)
if (type(ret) == type(NotImplemented)):
return NotImplemented
ret_unit = unit_resolver(self.fn_name, arg_units)
if (ret_unit == NotImplemented):
def __new__(cls, value, unit):
# generate a new subclass for value
value_class = type(value)
try:
subcls = type('TaggedValue_of_%s' % (value_class.__name__),
tuple([cls, value_class]),
{})
src/m/d/md-HEAD/docs/examples/stm_shelf.py md(Download)
def __copy__(self):
return allocated(type(self), copy_state(readable(self)))
def __reduce__(self):
return (delayed, (type(self), pid(self)))
__id__ = property(pid)
kwargs.pop('__id__', None)
base.__init__(self, *args, **kwargs)
return type(name, (PCursor, base), dict(
__slots__ = ('__pid__', ),
__module__ = __name__,
__init__ = __init__,
if is_deleted(state):
del self.store[key]
else:
self.store[key] = (type(cursor), state)
self.store.sync()
def delayed(self, cls, id):
src/p/y/pyjamas-0.7/examples/libtest/ClassTest.py Pyjamas(Download)
def testMetaClass(self):
Klass = type('MyClass', (object,), {'method': method, 'x': 5})
instance = Klass()
self.assertEqual(instance.method(), 1)
self.assertEqual(instance.x, 5)
def testMetaClassInheritFromType(self):
class Metaklass(type):
class MetaklassDctSaver(type):
def __init__(cls, name, bases, dct):
super(MetaklassDctSaver, cls).__init__(name, bases, dct)
cls.saved_dct = dct
class MyClass(object):
__metaclass__ = MetaklassDctSaver
a = 1
src/d/i/diksel-HEAD/trunk/thirdparty/pyjamasdev/examples/libtest/ClassTest.py diksel(Download)
def testMetaClass(self):
Klass = type('MyClass', (object,), {'method': method, 'x': 5})
instance = Klass()
self.assertEqual(instance.method(), 1)
self.assertEqual(instance.x, 5)
def testMultiSuperclass(self):
src/p/y/python-cookbook-HEAD/cb2_examples/cb2_6_6_sol_1.py python-cookbook(Download)
cls = known_proxy_classes.get(key)
if cls is None:
# we don't have a suitable class around, so let's make it
cls = type("%sProxy" % obj_cls.__name__, (Proxy,), {})
for name in specials:
name = '__%s__' % name
unbound_method = getattr(obj_cls, name)
setattr(cls, name, make_binder(unbound_method))
# also cache it for the future
known_proxy_classes[key] = cls
# instantiate and return the needed proxy
return cls(obj)
src/d/i/diksel-HEAD/thirdparty/pyjamasdev/examples/libtest/ClassTest.py diksel(Download)
def testMetaClass(self):
Klass = type('MyClass', (object,), {'method': method, 'x': 5})
instance = Klass()
self.assertEqual(instance.method(), 1)
self.assertEqual(instance.x, 5)
def testMultiSuperclass(self):
src/m/d/md.py-0.2/docs/examples/stm_shelf.py md.py(Download)
def __copy__(self):
return allocated(type(self), copy_state(readable(self)))
def __reduce__(self):
return (delayed, (type(self), pid(self)))
__id__ = property(pid)
kwargs.pop('__id__', None)
base.__init__(self, *args, **kwargs)
return type(name, (PCursor, base), dict(
__slots__ = ('__pid__', ),
__module__ = __name__,
__init__ = __init__,
if is_deleted(state):
del self.store[key]
else:
self.store[key] = (type(cursor), state)
self.store.sync()
def delayed(self, cls, id):
src/g/p/gpyconf-HEAD/examples/unittests/all_fields.py gpyconf(Download)
_dict['frontend'] = gpyconf.frontends.gtk.ConfigurationDialog.with_arguments(title='All Fields',
ignore_missing_widgets=True)
AllFieldsTest = type('AllFieldsTest', (Configuration,), _dict)
# generate the class
if __name__ == '__main__':
#from gpyconf.backends.python import PythonModuleBackend as BACKEND
#from gpyconf.backends._json import JSONBackend as BACKEND
from gpyconf.backends._xml import XMLBackend as BACKEND
#from gpyconf.backends.configparser import ConfigParserBackend as BACKEND
test = AllFieldsTest(backend=BACKEND)
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 Next