June 18th, 2004, 09:43 PM
How come Python never implemented a ``stronger'' (is that the right word?) OOP system (ie. more like C++/Java) with private/public stuff?
June 18th, 2004, 11:22 PM
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.
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.
print "Hello from Method 1"
print "Method 2"
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
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
June 19th, 2004, 10:13 AM
Woah, I never new that . Is it the same for variables?
June 19th, 2004, 06:43 PM
Because it's not useful to artificially restrict the visibility to things within classes. Especially not in a language like Python.
Originally Posted by NetBSD