Python Tutorial

Tuesday, August 28, 2012

Python public and private class

Sometimes we need to make class public and private also.

Lets see python syntex how to do it

class MyClass(): def myPublicFunction(self): print "I am public function" def __myPrivateFunction(self): print "I am private function" class _MyPrivateClass(): def myPrivateFunction(self): print "I am private function of class _MyPrivateClass"

from privateClassSample import * a=MyClass() a.myPublicFunction() #b=_MyPrivateClass() # this willl not work, _MyPrivateClass is private class

I am public function


Post a Comment