jQuery in Action, 3rd edition
The moose likes Jython/Python and the fly likes OO in Python Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Jython/Python
Bookmark "OO in Python" Watch "OO in Python" New topic

OO in Python

Robert Hill
Ranch Hand

Joined: Feb 24, 2006
Posts: 94
Is there any encapsulation in python objects?

There is the convention to use a single underscore to denote private members, but is not enforced in any way.

Using double underscore mangles it a bit, but is used to avoid naming conflicts.

It seems like python OO is like faking OO in C.
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

The forum right below this one (Object Oriented Scripting) has Python as one of its subjects. So I'll move this post down there.
Joe Ess

Joined: Oct 29, 2001
Posts: 9189

Originally posted by Robert Hill:

It seems like python OO is like faking OO in C.

Yes, some of Python's object support is by convention rather than forced on you by the language, but you have to appreciate that Python is ment to be a lighter-weight language than, say Java, from a syntax point of view. If you want strict OO features, use Smalltalk. If you want to write something quick and dirty, use a scripting language. If you want a good balance between those two extremes, Python makes a good compromise.

[How To Ask Questions On JavaRanch]
I agree. Here's the link: http://aspose.com/file-tools
subject: OO in Python
jQuery in Action, 3rd edition