mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-09 22:49:57 +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.
16 lines
225 B
Python
16 lines
225 B
Python
class Foo:
|
|
def __init__(self, x):
|
|
assert x == 5
|
|
self.x = x
|
|
|
|
def square(self):
|
|
return self.x * self.x
|
|
|
|
y = 7
|
|
|
|
foo = Foo(5)
|
|
|
|
assert foo.y == Foo.y
|
|
assert foo.x == 5
|
|
assert foo.square() == 25
|