Skip to content

Instantly share code, notes, and snippets.

@vielhuber
Last active June 25, 2025 12:16
Show Gist options
  • Save vielhuber/a0d7ae61eba9bb717e55e1a2ab2940f4 to your computer and use it in GitHub Desktop.
Save vielhuber/a0d7ae61eba9bb717e55e1a2ab2940f4 to your computer and use it in GitHub Desktop.
object oriented programming classes #python
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