Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OO in Python

 
Robert Hill
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Bartender
Posts: 9312
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic