Coding Objects in Python

I’m going to slowly add content in this posting but the topic is how code objects in python.

Everything in Python is consider an object and tricky to keep track of everything you can do with objects.

Here is a basic structure of a class

class foo:

The class object foo doesn’t do much so next I’m going to make a point object.  This class will have a constructor that takes in two inputted objects and a method to return the x and y positions of the point.

class point:

# Constructor - Note: No checks on inputted values.

def __init__(self, Incoming_X, Incoming_Y):

self.x =Incoming_X

self.y = Incoming_Y

# Get Method: Returns x & y as a list

def get():

return([self.x, self.y])

You can also use classes with decorators


class foo:

Additional Reading
IBM’s developerWorks Python 3 Primer

PEP 3129 – Class Decorators


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s