Commit 62956963 authored by Tom Niget's avatar Tom Niget

Add example for methods and fields

parent 420d71ea
import pyext import pyext
print("Imported:", pyext.add(5, 3), pyext.fibo(10), pyext.squares(), pyext.Person("jean", 123)) p = pyext.Person("jean", 123)
\ No newline at end of file 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: ...@@ -9,8 +9,9 @@ class Person:
name: str name: str
age: int age: int
def afficher(self): def afficher(self, msg: str):
print(self.name, self.age) print(msg, ",", self.name, self.age)
return 123
def add(x, y): def add(x, y):
return x + y return x + y
...@@ -25,4 +26,6 @@ def squares() -> list[int]: ...@@ -25,4 +26,6 @@ def squares() -> list[int]:
return np.square([x for x in range(5)]) return np.square([x for x in range(5)])
if __name__ == "__main__": if __name__ == "__main__":
print("Python:", add(5, 3), fibo(10), squares(), Person("jean", 123)) p = Person("jean", 123)
\ No newline at end of file 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