Created
November 16, 2014 23:32
-
-
Save pzp1997/d8d0825040b9944725dd to your computer and use it in GitHub Desktop.
Example of a very basic class.
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
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