Adinda
1
I still confuse about class and function in python. for example this code.
···
===
class FirstClass(Something1):
def Function1( self, lastAction):
{some codes}
variable1 = self.Function2(arg1, arg2)
variable2 = self.Function3(variable1)
{some codes}
self.Function4(variable2)
{some codes}
self.Function1("DoSomething")
def Function2(self, arg1, arg2):
{some codes}
def Function3(self, variable1):
{some codes}
self.Function1("DoAnotherThing")
{some codes}
def Function4(self, variable2):
{some codes}
How to understand this code? What’s the main code for the class? how can i know that?
Best Regards,
Adinda
In this instance, there is no main code. Your main code goes after class definitions, where you would instanciate an object, and use it.
If you are refering to a constructor, you need to define a function called init, like this:
``
def __init__(self):
#do stuff here
``
get it?
Hope I helped
···
On Fri, 2001-12-28 at 19:40, Adinda wrote:
I still confuse about class and function in python. for example this code.
*===*
*class FirstClass(Something1):*
*def Function1( self, lastAction):*
*{some codes}*
*variable1 = self.Function2(arg1, arg2)*
**
*variable2 = self.Function3(variable1)*
**
*{some codes}*
**
*self.Function4(variable2)*
**
*{some codes}*
**
*self.Function1("DoSomething")*
**
*def Function2(self, arg1, arg2):*
*{some codes}*
**
*def Function3(self, variable1):*
*{some codes}*
**
*self.Function1("DoAnotherThing")*
**
*{some codes}*
**
*def Function4(self, variable2):*
*{some codes}*
*=== *
*How to understand this code? What's the main code for the class? how can i know that? *
**
*Best Regards,*
**
*Adinda*