Skip to content

Instantly share code, notes, and snippets.

@hoangtuan151
Last active October 20, 2022 05:59
Show Gist options
  • Save hoangtuan151/a9116405f1e2955d8aca8ef2d1e3d5c7 to your computer and use it in GitHub Desktop.
Save hoangtuan151/a9116405f1e2955d8aca8ef2d1e3d5c7 to your computer and use it in GitHub Desktop.
class Student:
def __init__(self, name) -> None:
self.Name = name
def __str__(self) -> str:
return f"Student({self.Name})"
def change_student(s: Student):
s.Name = "AAA"
s = Student("New name")
s.Name = "BBB"
print(f"function: {s}")
def main():
a = Student("john")
print(f"main: {a}")
change_student(a)
print(f"main: {a}")
====== OUTPUT ======
main: Student(john)
function: Student(BBB)
main: Student(AAA)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment