objectpython.py
· 212 B · Python
Raw
# here is a very simple example of python OOP
# normal hello-world
print("1 Hello World!")
# an OOP version
class HelloWorld:
def main(self):
print("2 Hello World!")
obj = HelloWorld()
obj.main()
1 | # here is a very simple example of python OOP |
2 | |
3 | # normal hello-world |
4 | print("1 Hello World!") |
5 | |
6 | # an OOP version |
7 | |
8 | class HelloWorld: |
9 | def main(self): |
10 | print("2 Hello World!") |
11 | |
12 | obj = HelloWorld() |
13 | obj.main() |
14 |