[Tutor] Object Oriented Programmin

Pujo Aji ajikoe at gmail.com
Tue Mar 28 10:16:34 CEST 2006

Object is object, means like ordinary object we know.
Let's say good things about objecs paradigm.

First you can create object of course. object can contain property and

You can put your object as part as other object. It makes sense since for
example object hand is part of object body in human term.

You can derive a new object from your old one (with its property and
action). You can, in this new object,  add a new function or change the
function from the old one. This will make your old object untouchable and
your new object easy to build (you don't have to build from the start)

Let's start with a simple code.
We can create a simple dog class

class dog:
    def __init__(self, name):
        self.name = name
    def action(self):
        print 'run'

class doberman(dog):
    def __init__(self, name):
    def bark(self):
        print 'wuu'

class coco(dog):
    def __init__(self, name):

    def action(self):
        print 'jump'

    def bark(self):
        print 'waa'
d1 = doberman('deni')
d1.action()      # 'run'
d1.bark()        # 'wuu'

d2 = coco('mayin')
d2.action() # 'jump'
d2.bark()    # 'waa'

Each has name as an ID.
a doberman uses the same action like dog class
a coco uses  different action than the original action from dog which is

In this example we can see we can change one object easily and doesn't
change the original class which is dog. This make less prone to error.

both doberman and coco can use bark but the result will be different
both doberman and coco can access name this also result in different way.
It is nice since you can use the same word bark to all of the new dogs
you've created.

I try to describe as simple as I can. In this example you can put another
function like getname in dog class so that all type of dogs has this
function automaticaly.

Hope this help

On 3/28/06, Kaushal Shriyan <kaushalshriyan at gmail.com> wrote:
> Hi ALL
> I have gone through the object oriented programming in Python, I am
> not able to understand OOP concept in python,
> is there a methodical way to understand it and simplfy things
> Thanks in Advance
> Regards
> Kaushal
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060328/ecadd4f9/attachment.html 

More information about the Tutor mailing list