Files
RustPython/tests/snippets/class.py
Adam Kelly ca7b792497 Get both forms of type to work properly.
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.
2018-08-18 11:54:00 +01:00

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