Last active
June 25, 2025 12:16
-
-
Save vielhuber/a0d7ae61eba9bb717e55e1a2ab2940f4 to your computer and use it in GitHub Desktop.
object oriented programming classes #python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
# ... | |
class Example: | |
staticVariable = "baz" | |
def __init__(self): | |
self.attr1 = "foo" | |
self.attr2 = "bar" | |
self.attr3 = "baz" | |
def test1(self): | |
print(self.attr1) | |
self.attr1 = "foo42" | |
print(self.attr1) | |
self.test2("foo") | |
def test2(self, str): | |
print(str) | |
def main(self): | |
print("start!") | |
self.test1() | |
example = Example() | |
example.main() | |
print(Example.staticVariable) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment