[Tutor] Newbie OOP Question.

Andrei Kulakov ak@silmarill.org
Sat, 8 Jun 2002 13:35:44 -0400


On Sat, Jun 08, 2002 at 11:29:32AM -0500, SA wrote:
> Hi Everyone-
> 
>     I'm still trying to grasp this OOP concept in Python. Can someone tell
> me the difference between a function, a module, and a class? Since Python
> defines them all as objects, how do they differ outside of being called from
> inside the script or outside the script?
> 
> Thanks.
> SA
> 
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor

Module is a file that has some code in it. Module may include many
functions and classes in it (or just a few lines of code. A function is
a chunk of code that may take in some data and then return some other
data:

def func(data_in):
    [do stuff]
    return data_out

a class usually contains a few functions, say a Tree class would have
grow_roots and grow_leaves functions, and would also have a boolean
attribute alive: tree.alive = 1. Oh, and there'd be a function tree.die
that would set tree.alive to 0.

-- 
Cymbaline: intelligent learning mp3 player - python, linux, console.
get it at: cy.silmarill.org