Monday, October 19, 2009

Simple python class

Teaching myself the basics of python. With all the info on the net its hard to find a simple example that demonstrates a python class. This little bit of code demonstrates a class in a simple to understand way.


class myclass:
def __init__(self):
print "Constructor init - how we create ourselves"
def __str__(self):
return "This is how we print ourselves"
def __del__(self):
print "Destructor - how we delete ourselves"

x=myclass()
print x

No comments:

Post a Comment