Skip to content

Instantly share code, notes, and snippets.

@pzp1997
Created November 16, 2014 23:32
Show Gist options
  • Save pzp1997/d8d0825040b9944725dd to your computer and use it in GitHub Desktop.
Save pzp1997/d8d0825040b9944725dd to your computer and use it in GitHub Desktop.
Example of a very basic class.
class myClass(object):
def __init__(self, myInt):
self.myString = "Hello"
self.myInt = myInt
def foo(self):
self.myString = self.myString + " world."
def add(self, n):
self.myInt += n
myInstance = myClass(3)
print(myInstance.myString)
myInstance.foo()
print(myInstance.myString)
print()
print(myInstance.myInt)
myInstance.add(4)
print(myInstance.myInt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment