Python Tutorial

Tuesday, August 28, 2012

Python class public method and private method

Sometimes we need to make some private and public function for a class.
Lets see python syntex for such class
class MyClass(): def myPublicFunction(self): print "I am public function" def __myPrivateFunction(self): print "I am private function" myClass= MyClass() myClass.myPublicFunction() #myClass.__myPrivateFunction # This is will not work, __myPrivateFunction private method

I am public function


Post a Comment