
June 18th, 2004, 11:22 PM
|
 |
Banned ;)
|
|
Join Date: Nov 2001
Location: Woodland Hills, Los Angeles County, California, USA
|
|
Python does have private and public methods (no protected though). If you prefix a method name with __, then it is only visible within that class.
Code:
class class1:
def method1(self):
print "Hello from Method 1"
def __method2(self):
print "Method 2"
def method3(self):
self.__method2()
In the above code, method1() and method3() are public and can be accessed from other modules, but __method2() can only be accessed from within this class.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
|