Re: About classes and OOP in Python

2006-04-12 Thread bruno at modulix
Gregor Horvath wrote: > Steven D'Aprano schrieb: > > >>I don't know of many other OO languages that didn't/don't have >>inheritance, > > > VB4 - VB6 > VB6 has a kind of inheritance via interface/delegation. The interface part is for subtyping, the delegation part (which has to be done manuall

Re: About classes and OOP in Python

2006-04-12 Thread Magnus Lycka
Michele Simionato wrote: > Roy Smith wrote: > >> That being said, you can indeed have private data in Python. Just prefix >> your variable names with two underscores (i.e. __foo), and they effectively >> become private. Yes, you can bypass this if you really want to, but then >> again, you can b

Re: About classes and OOP in Python

2006-04-12 Thread bruno at modulix
Casey Hawthorne wrote: >>I think it's important not to wrongly confuse 'OOP' with ''data hiding' >>or any other aspect you may be familiar with from Java or C++. The >>primary concept behind OOP is not buzzwords such as abstraction, >>encapsulation, polymorphism, etc etc, but the fact that your pro

Re: About classes and OOP in Python

2006-04-12 Thread bruno at modulix
Ben C wrote: > On 2006-04-11, Michele Simionato <[EMAIL PROTECTED]> wrote: > >>Roy Smith wrote: >> >> >>>That being said, you can indeed have private data in Python. Just prefix >>>your variable names with two underscores (i.e. __foo), and they effectively >>>become private. Yes, you can bypass

Re: About classes and OOP in Python

2006-04-11 Thread Gregor Horvath
Steven D'Aprano schrieb: > I don't know of many other OO languages that didn't/don't have > inheritance, VB4 - VB6 -- Mit freundlichen Grüßen, Ing. Gregor Horvath, Industrieberatung & Softwareentwicklung http://www.gregor-horvath.com -- http://mail.python.org/mailman/listinfo/python-list

Re: About classes and OOP in Python

2006-04-11 Thread Ben Cartwright
Michele Simionato wrote: > Roy Smith wrote: > > > That being said, you can indeed have private data in Python. Just prefix > > your variable names with two underscores (i.e. __foo), and they effectively > > become private. Yes, you can bypass this if you really want to, but then > > again, you c

Re: About classes and OOP in Python

2006-04-11 Thread Steven D'Aprano
On Tue, 11 Apr 2006 18:20:13 +, Casey Hawthorne wrote: >>I think it's important not to wrongly confuse 'OOP' with ''data hiding' >>or any other aspect you may be familiar with from Java or C++. The >>primary concept behind OOP is not buzzwords such as abstraction, >>encapsulation, polymorphism

Re: About classes and OOP in Python

2006-04-11 Thread Ben C
On 2006-04-11, Michele Simionato <[EMAIL PROTECTED]> wrote: > Roy Smith wrote: > >> That being said, you can indeed have private data in Python. Just prefix >> your variable names with two underscores (i.e. __foo), and they effectively >> become private. Yes, you can bypass this if you really wan

Re: About classes and OOP in Python

2006-04-11 Thread Casey Hawthorne
>I think it's important not to wrongly confuse 'OOP' with ''data hiding' >or any other aspect you may be familiar with from Java or C++. The >primary concept behind OOP is not buzzwords such as abstraction, >encapsulation, polymorphism, etc etc, but the fact that your program >consists of objects m

Re: About classes and OOP in Python

2006-04-11 Thread bruno at modulix
Roy Smith wrote: (snip) > That being said, you can indeed have private data in Python. Just prefix > your variable names with two underscores (i.e. __foo), and they effectively > become private. The double-leading-underscore stuff has nothing to do with "privacy". It's meant to protect from

Re: About classes and OOP in Python

2006-04-11 Thread bruno at modulix
fyhuang wrote: > Hello all, > > I've been wondering a lot about why Python handles classes and OOP the > way it does. From what I understand, there is no concept of class > encapsulation in Python, i.e. no such thing as a private variable. Seems you're confusing encapsulation with data hiding. >

Re: About classes and OOP in Python

2006-04-11 Thread Michele Simionato
Roy Smith wrote: > That being said, you can indeed have private data in Python. Just prefix > your variable names with two underscores (i.e. __foo), and they effectively > become private. Yes, you can bypass this if you really want to, but then > again, you can bypass private in C++ too. Wrong,

Re: About classes and OOP in Python

2006-04-11 Thread Fredrik Lundh
Ben Sizer wrote: > I think it's important not to wrongly confuse 'OOP' with ''data hiding' > or any other aspect you may be familiar with from Java or C++. The > primary concept behind OOP is not buzzwords such as abstraction, > encapsulation, polymorphism, etc etc, but the fact that your program

Re: About classes and OOP in Python

2006-04-11 Thread Ben Sizer
fyhuang wrote: > It seems to me that it is difficult to use OOP to a wide extent in > Python code because these features of the language introduce many > inadvertant bugs. For example, if the programmer typos a variable name > in an assignment, the assignment will probably not do what the > program

Re: About classes and OOP in Python

2006-04-10 Thread Gregor Horvath
Hi, fyhuang schrieb: > I've been wondering a lot about why Python handles classes and OOP the > way it does. From what I understand, there is no concept of class > encapsulation in Python, i.e. no such thing as a private variable. Any the answer is here: http://tinyurl.com/obgho -- Mit freund

Re: About classes and OOP in Python

2006-04-10 Thread Sion Arrowsmith
fyhuang <[EMAIL PROTECTED]> wrote: > [ ... ] no such thing as a private variable. Any >part of the code is allowed access to any variable in any class, and >even non-existant variables can be accessed: they are simply created. You're confusing two issues: encapsulation and dynamic name binding. Yo

Re: About classes and OOP in Python

2006-04-10 Thread Felipe Almeida Lessa
Em Seg, 2006-04-10 às 07:19 -0700, fyhuang escreveu: > class PythonClass: >private foo = "bar" >private var = 42 >allow_readwrite( [ foo, var ] ) You are aware that foo and var would become class-variables, not instance-variables, right? But you can always do: class PythonClass(objec

Re: About classes and OOP in Python

2006-04-10 Thread Roy Smith
"fyhuang" <[EMAIL PROTECTED]> wrote: > I've been wondering a lot about why Python handles classes and OOP the > way it does. From what I understand, there is no concept of class > encapsulation in Python, i.e. no such thing as a private variable. Any > part of the code is allowed access to any vari

Re: About classes and OOP in Python

2006-04-10 Thread [EMAIL PROTECTED]
You can do this in Python as well. Check out the property built-in function. One can declare a property with a get, set, and delete method. Here's a small example of a read-only property. class Test(object): def getProperty(self): return 0; prop = property(fget = getProperty)

About classes and OOP in Python

2006-04-10 Thread fyhuang
Hello all, I've been wondering a lot about why Python handles classes and OOP the way it does. From what I understand, there is no concept of class encapsulation in Python, i.e. no such thing as a private variable. Any part of the code is allowed access to any variable in any class, and even non-e