class vs function ???

Gaurav Veda gveda at iitk.ac.in
Sun Feb 22 01:26:14 EST 2004


Hi !

I have read all the replies and they are all extremely helpful. Thanks
a lot !!!
My basic doubts were :
1) I am allowed to write things in the class body without the need for
encapsulating them in functions. Moreover, they are executed as soon
as I define the class. Infact, I can also call functions in the class
body (the way  I called fun2). All this, while I am just defining the
class !	-- I still don't understand why are classes implemented in
this way in pyhton.

2) The reason I had that erroneous 'print c' statement was, because I
just wanted to point out that it seems like the scoping rules for both
classes and functions are the same. -- I now understand the scoping
rules and realize the fallacy. Thanks again !

Being a 3rd year undergraduate student, I have to make a Python
'compiler' (I know it sounds foolish -- but thats what my instructor
wants me to do !). This is the precise reason why I am tinkering with
Python and trying to figure out the exact way in which things work !

Gaurav

PS : No Steve, I am not trying out any tricks here. Believe me, I know
too little to do any of that :)



More information about the Python-list mailing list