mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-17 01:51:39 +09:00
Includes basic ability to traverse method resolution order (mro), but not to derive mro or read parents from class definitions. New and init called when creating types and instances. __call__ works on types and instances. Descriptors have have priority over instance variables.
17 lines
368 B
Python
17 lines
368 B
Python
assert type(type) is type
|
|
assert type(object) is type
|
|
assert type(object()) is object
|
|
|
|
new_type = type('New', (object,), {})
|
|
|
|
assert type(new_type) is type
|
|
assert type(new_type()) is new_type
|
|
|
|
metaclass = type('MCl', (type,), {})
|
|
cls = metaclass('Cls', (object,), {})
|
|
inst = cls()
|
|
|
|
assert type(inst) is cls
|
|
assert type(cls) is metaclass
|
|
assert type(metaclass) is type
|