Commit 62956963 authored by Tom Niget's avatar Tom Niget

Add example for methods and fields

parent 420d71ea
import pyext
print("Imported:", pyext.add(5, 3), pyext.fibo(10), pyext.squares(), pyext.Person("jean", 123))
\ No newline at end of file
p = pyext.Person("jean", 123)
print("Imported:", pyext.add(5, 3), pyext.fibo(10), pyext.squares(), p)
print(p.afficher("Bonjour"))
print(p.name, p.age)
\ No newline at end of file
......@@ -9,8 +9,9 @@ class Person:
name: str
age: int
def afficher(self):
print(self.name, self.age)
def afficher(self, msg: str):
print(msg, ",", self.name, self.age)
return 123
def add(x, y):
return x + y
......@@ -25,4 +26,6 @@ def squares() -> list[int]:
return np.square([x for x in range(5)])
if __name__ == "__main__":
print("Python:", add(5, 3), fibo(10), squares(), Person("jean", 123))
\ No newline at end of file
p = Person("jean", 123)
print("Python:", add(5, 3), fibo(10), squares(), p)
p.afficher("Bonjour")
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment