[OT] Re: Why does python not have a mechanism for data hiding?

2008-06-12 Thread Bruno Desthuilliers
Dennis Lee Bieber a écrit : On Wed, 11 Jun 2008 10:10:14 +0200, Bruno Desthuilliers [EMAIL PROTECTED] declaimed the following in comp.lang.python: are some *very* talented and *experimented* programmers here. Pardon, but I think you mean experienced. Indeed. Tim Golden already

Re: Why does python not have a mechanism for data hiding?

2008-06-12 Thread Luis Zarrabeitia
Quoting Dennis Lee Bieber [EMAIL PROTECTED]: On Wed, 11 Jun 2008 21:54:33 -0700 (PDT), Michele Simionato [EMAIL PROTECTED] declaimed the following in comp.lang.python: It looks like in French (as in Italian) *experimented* has the meaning of tried and tested on the field when applied

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Niklas Norrthon
On 6 Juni, 03:09, Russ P. [EMAIL PROTECTED] wrote: On Jun 5, 2:57 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Russ P. [EMAIL PROTECTED] writes: By the way, my recollection is that in C++ access defaults to private if nothing is declared explicity. So normally the private declaration is

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Russ P.
On Jun 10, 11:58 am, Jonathan Gardner Who cares what the type of an object is? Only the machine. Being able to tell, in advance, what the type of a variable is is a premature optimization. Tools like psyco prove that computers (really, programmers) nowadays are smart enough to figure things

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread cokofreedom
On Jun 11, 8:11 am, Russ P. [EMAIL PROTECTED] wrote: On Jun 10, 11:58 am, Jonathan Gardner Who cares what the type of an object is? Only the machine. Being able to tell, in advance, what the type of a variable is is a premature optimization. Tools like psyco prove that computers (really,

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 10, 1:04 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: If you hope to get a general agreement here in favor of a useless keyword that don't bring anything to the language, then yes, I'm afraid you're wasting your time. Actually, what I hope to do is to take

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 10, 11:58 am, Jonathan Gardner (snip) Who cares about private declarations, or interface declarations at all? It is only a message to the developers. If you have a problem with your users doing the right thing, that is a social problem, not a technical one, and the

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Maric Michaud
Le Wednesday 11 June 2008 08:11:02 Russ P., vous avez écrit : http://www.sofcheck.com Here is an excerpt from their website: SofCheck’s advanced static error detection solutions find bugs in programs before programs are run. By mathematically analyzing every line of software, considering

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Paul Boddie
On 11 Jun, 10:10, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Russ P. a écrit : You may be right to an extent for small or medium-sized non-critical projects, but you are certainly not right in general. I read something a while back about the flight software for the Boeing 777. I

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Russ P.
On Jun 11, 2:36 am, Paul Boddie [EMAIL PROTECTED] wrote: Maybe, but I'd hope that some of those programmers would be at least able to entertain what Russ has been saying rather than setting themselves up in an argumentative position where to concede any limitation in Python might be

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Patrick Mullen
On Wed, Jun 11, 2008 at 12:28 PM, Russ P. [EMAIL PROTECTED] wrote: If Desthuilliers doesn't like my suggestion, then fine. If no other Python programmer in the world likes it, then so be it. But do we really need to get personal about it? Python will not be ruined if it gets such a keyword,

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Paul Boddie
On 11 Jun, 21:28, Russ P. [EMAIL PROTECTED] wrote: All I did was to suggest that a keyword be added to Python to designate private data and methods without cluttering my cherished code with those ugly leading underscores all over the place. I don't like that clutter any more than I like all

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Michele Simionato
On Jun 12, 6:43 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Wed, 11 Jun 2008 10:10:14 +0200, Bruno Desthuilliers [EMAIL PROTECTED] declaimed the following in comp.lang.python: are some *very* talented and *experimented* programmers here. Pardon, but I think you mean

Re: Why does python not have a mechanism for data hiding?

2008-06-11 Thread Ben Finney
Michele Simionato [EMAIL PROTECTED] writes: On Jun 12, 6:43 am, Dennis Lee Bieber [EMAIL PROTECTED] wrote: Pardon, but I think you mean experienced. Of course, GvR may qualify as experimented if one considers designing a language from scratch to be an experiment G It

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 9, 2:10 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: But if it takes 6 month to get the mentioned developer to release something I can use, I'm screwed up. Fine. I've lost track of how many times I've said this now, but my suggestion for a priv keyword allowed for

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Antoon Pardon
On 2008-06-09, Lie [EMAIL PROTECTED] wrote: That seems strange to me. The and-or simulation that was offerd in the FAQ allowed for about the same kind of structures as the ternary operator in C and was used in the standard library IIRC. So the same unreadable was already possible to write,

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Russ P.
On Jun 10, 1:04 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: If you hope to get a general agreement here in favor of a useless keyword that don't bring anything to the language, then yes, I'm afraid you're wasting your time. Actually, what I hope to do is to take something away

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Patrick Mullen
Hi Russ, Here are just some pragmatic considerations. Personally I am against data hiding, but I obviously won't convince you in that regard. There are some pros and cons as with anything, and I feel the cons outweight the pros (namely that users of code should be able to use how they want,

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Jonathan Gardner
On Jun 10, 11:21 am, Russ P. [EMAIL PROTECTED] wrote: I took a risk in choosing Python, and I would feel better about it if Python would move up to the next level with more advanced features such as (optional) static typing and private declarations. But every time I propose something like

Re: Why does python not have a mechanism for data hiding?

2008-06-10 Thread Samuel Bayer
Jonathan Gardner wrote: Let me share my personal insight. I used Python for a mission-critical application that needed, in effect, almost 100% uptime with superior throughput. In other words, it was a very fine piece of art that needed to be precise and correct. In the end, Python delivered,

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Mark Wooding a écrit : Russ P. [EMAIL PROTECTED] wrote: The idea of being able to discern properties of an object by its name alone is something that is not normally done in programming in general. Really? You obviously haven't noticed Prolog, Smalltalk, Haskell, ML, or Erlang then. And

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 8, 5:40 am, Mark Wooding [EMAIL PROTECTED] wrote: Russ P. [EMAIL PROTECTED] wrote: The idea of being able to discern properties of an object by its name alone is something that is not normally done in programming in general. Really? You obviously haven't noticed

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Mark Wooding a écrit : Fuzzyman [EMAIL PROTECTED] wrote: So, you are stating that no API programmer using Python *ever* has a valid or genuine reason for wanting (even if he can't have it) genuine 'hiding' of internal state or members from consumers of his (or her...) API? I don't want to

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 6, 8:25 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: I also realize, by the way, that Python allows a client of a class to define a new class member from completely outside the class definition. Obviously, that cannot be declared private. Why so ? Why

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Antoon Pardon
On 2008-06-07, BJörn Lindqvist [EMAIL PROTECTED] wrote: On Wed, Jun 4, 2008 at 2:02 PM, Antoon Pardon [EMAIL PROTECTED] wrote: Now of course noone would defend such a limitation on the grounds that one doesn't need the general case and that the general case will only save you some vertical

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Lie
On Jun 9, 7:20 pm, Antoon Pardon [EMAIL PROTECTED] wrote: On 2008-06-07, BJörn Lindqvist [EMAIL PROTECTED] wrote: On Wed, Jun 4, 2008 at 2:02 PM, Antoon Pardon [EMAIL PROTECTED] wrote: Now of course noone would defend such a limitation on the grounds that one doesn't need the general case

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Russ P.
On Jun 9, 2:23 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Mark Wooding a écrit : Fuzzyman [EMAIL PROTECTED] wrote: So, you are stating that no API programmer using Python *ever* has a valid or genuine reason for wanting (even if he can't have it) genuine 'hiding' of

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Russ P.
On Jun 9, 2:22 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Does anyone object to not having access from outside a function to local variables within the function? I doubt it. The other thing is that the vast majority of Python software, I would guess, is provided with source

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread [EMAIL PROTECTED]
On 9 juin, 20:43, Russ P. [EMAIL PROTECTED] wrote: (snip argument about s/private/public/g on a whole source tree not being a fork, and not being by far a worse hack than monkeypatching a small specific part of a whole lib - what can I say ?) How about some common sense here. Good question.

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Russ P.
On Jun 9, 2:10 pm, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: But if it takes 6 month to get the mentioned developer to release something I can use, I'm screwed up. Fine. I've lost track of how many times I've said this now, but my suggestion for a priv keyword allowed for indirect access to

Re: Why does python not have a mechanism for data hiding?

2008-06-09 Thread Fuzzyman
On Jun 9, 10:23 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Mark Wooding a écrit : Fuzzyman [EMAIL PROTECTED] wrote: So, you are stating that no API programmer using Python *ever* has a valid or genuine reason for wanting (even if he can't have it) genuine 'hiding' of

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Paul Rubin http wrote: This is bogus about 95% of the time though. For the cases where it is really desired, I think it's best to require the target class to be enable it specifically somehow, maybe by inheriting from a special superclass. That could let the compiler statically resolve

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Hrvoje Niksic [EMAIL PROTECTED] wrote: How about #define class struct Won't work. Consider `templateclass T ...'. -- [mdw] -- http://mail.python.org/mailman/listinfo/python-list

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Russ P. [EMAIL PROTECTED] wrote: The idea of being able to discern properties of an object by its name alone is something that is not normally done in programming in general. Really? You obviously haven't noticed Prolog, Smalltalk, Haskell, ML, or Erlang then. And that's just the ones I

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Mark Wooding
Fuzzyman [EMAIL PROTECTED] wrote: So, you are stating that no API programmer using Python *ever* has a valid or genuine reason for wanting (even if he can't have it) genuine 'hiding' of internal state or members from consumers of his (or her...) API? I don't want to speak for whoever you

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Roy Smith
In article [EMAIL PROTECTED], Mark Wooding [EMAIL PROTECTED] wrote: * Prolog and Erlang distinguish atoms from variables by the case of the first letter; also `_' is magical and is equivalent to a new variable name every time you use it. Can you explain that in more detail? A

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Roy Smith
In article [EMAIL PROTECTED], Mark Wooding [EMAIL PROTECTED] wrote: By enforcing your `data hiding', you're effectively telling me that I'm too stupid to make rational decisions of this sort. And that's actually extremely insulting. I think that's taking it a bit far. Python doesn't let

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Luis Zarrabeitia
I don't know about Erlang (though I'd think it's behaviour sould be similar to prolog), but at least in Prolog, yes, _ and _ are different variables. The whole idea of _ is that it is a placeholder that can bind to anything, but will be immediately discarded. It's just syntactic sugar so you

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Russ P.
On Jun 8, 5:52 am, Mark Wooding [EMAIL PROTECTED] wrote: By enforcing your `data hiding', you're effectively telling me that I'm too stupid to make rational decisions of this sort. And that's actually extremely insulting. 1) I suggest you not take it personally. 2) Local data within

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Russ P.
On Jun 8, 5:40 am, Mark Wooding [EMAIL PROTECTED] wrote: Russ P. [EMAIL PROTECTED] wrote: The idea of being able to discern properties of an object by its name alone is something that is not normally done in programming in general. Really? You obviously haven't noticed Prolog, Smalltalk,

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread John Salerno
Sh4wn wrote: data hiding. I know member vars are private when you prefix them with 2 underscores, but I hate prefixing my vars, I'd rather add a keyword before it. Others touched on this, but I thought I'd throw it in here as well since I was just reading about this. Apparently the double

Re: Why does python not have a mechanism for data hiding?

2008-06-08 Thread Patrick Mullen
Well, common in Prolog, Smalltalk, Haskell, ML, and Erlang is hardly common in general. I'll bet that Java and C/C++ are used more in North Dakota than all those languages combined are used in the entire world. I would say python has more in common with the mentioned family than with the C or

Re: Why does python not have a mechanism for data hiding?

2008-06-07 Thread BJörn Lindqvist
On Wed, Jun 4, 2008 at 2:02 PM, Antoon Pardon [EMAIL PROTECTED] wrote: Now of course noone would defend such a limitation on the grounds that one doesn't need the general case and that the general case will only save you some vertical space. But when it came to the ternary operator that was

Re: expression IF (was: Why does python not have a mechanism for data hiding?)

2008-06-07 Thread John Nagle
BJörn Lindqvist wrote: On Wed, Jun 4, 2008 at 2:02 PM, Antoon Pardon [EMAIL PROTECTED] wrote: Now of course noone would defend such a limitation on the grounds that one doesn't need the general case and that the general case will only save you some vertical space. But when it came to the

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread cokofreedom
Someone asked about Java; class FieldTest { public String publicString = Foobar; private String privateString = Hello, World!; } import java.lang.reflect.Field; public class Test4 { public static void main(String args[]) { final Field fields[] =

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 4, 4:29 am, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes, you can live with it, and it does no

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 5, 4:53 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Russ P. a écrit : Given your very recent discovery of what 'dynamic' *really* means in Python (like, for exemple, dynamically adding / replacing attributes - including methods - on a per-class or

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Bruno Desthuilliers
Russ P. a écrit : On Jun 5, 2:27 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Thu, 5 Jun 2008 11:36:28 -0700 (PDT), Russ P. [EMAIL PROTECTED] declaimed the following in comp.lang.python: would need to use a mangled name to access private data or methods. But you will be using the name

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Russ P.
On Jun 6, 8:25 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: I also realize, by the way, that Python allows a client of a class to define a new class member from completely outside the class definition. Obviously, that cannot be declared private. Why so ? Why should the

Re: Why does python not have a mechanism for data hiding?

2008-06-06 Thread Russ P.
On Jun 6, 8:28 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Russ P. a écrit : On Jun 5, 2:27 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Thu, 5 Jun 2008 11:36:28 -0700 (PDT), Russ P. [EMAIL PROTECTED] declaimed the following in comp.lang.python: would need to use a

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Antoon Pardon
On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 04 Jun 2008 09:34:58 +, Antoon Pardon wrote: On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: it makes sense to me to also test if they work as documented. If they affect the behaviour of some

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Marc 'BlackJack' Rintsch
On Thu, 05 Jun 2008 08:21:41 +, Antoon Pardon wrote: On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 04 Jun 2008 09:34:58 +, Antoon Pardon wrote: On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: it makes sense to me to also test if they work

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Antoon Pardon
On 2008-06-05, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Thu, 05 Jun 2008 08:21:41 +, Antoon Pardon wrote: On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: On Wed, 04 Jun 2008 09:34:58 +, Antoon Pardon wrote: On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Bruno Desthuilliers
Antoon Pardon a écrit : On 2008-06-04, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes, you can live with it, and it does no

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Bruno Desthuilliers
Russ P. a écrit : (snip) (answering to Carl Bank) I thought you were saying that encapsulation or so-called data hiding is worthless. As far as I'm concerned, I view encapsulation as very desirable, and data-hidding as totally worthless when applied to Python's object model. Here's what I

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Fuzzyman
On Jun 3, 6:54 pm, sturlamolden [EMAIL PROTECTED] wrote: On May 24, 3:41 pm, Sh4wn [EMAIL PROTECTED] wrote: first, python is one of my fav languages, and i'll definitely keep developing with it. But, there's 1 one thing what I -really- miss: data hiding. I know member vars are private when

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread sturlamolden
On Jun 5, 3:26 pm, Fuzzyman [EMAIL PROTECTED] wrote: So, you are stating that no API programmer using Python *ever* has a valid or genuine reason for wanting (even if he can't have it) genuine 'hiding' of internal state or members from consumers of his (or her...) API? Michael

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
On Jun 5, 4:47 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Antoon Pardon a écrit : On 2008-06-04, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread George Sakkis
On Jun 5, 2:07 pm, Russ P. [EMAIL PROTECTED] wrote: The private keyword goes further and prevents access even by derived classes. The double leading underscore in Python does no such thing. Who develops these derived classes ? A competitor ? A malicious hacker ? A spammer ? Who are you trying

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
On Jun 5, 4:53 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Russ P. a écrit : Given your very recent discovery of what 'dynamic' *really* means in Python (like, for exemple, dynamically adding / replacing attributes - including methods - on a per-class or per-instance basis),

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
On Jun 5, 11:25 am, George Sakkis [EMAIL PROTECTED] wrote: On Jun 5, 2:07 pm, Russ P. [EMAIL PROTECTED] wrote: The private keyword goes further and prevents access even by derived classes. The double leading underscore in Python does no such thing. Who develops these derived classes ? A

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
For the record, I have made it abundantly clear that I don't think Python should not have as rigorous an encapsulation regime as C++ or Java. The worst that could happen with my proposition is that you would need to use a mangled name to access private data or methods. But you will be using

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread [EMAIL PROTECTED]
On 5 juin, 20:07, Russ P. [EMAIL PROTECTED] wrote: On Jun 5, 4:47 am, Bruno Desthuilliers bruno. [EMAIL PROTECTED] wrote: Antoon Pardon a écrit : On 2008-06-04, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Roy Smith
In article [EMAIL PROTECTED], Russ P. [EMAIL PROTECTED] wrote: In C++ (and Java?), on the other hand, the protected keyword *really* prevents the client from accessing the data or method, but it allows access to derived classes. The private keyword goes further and prevents access even by

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
On Jun 5, 12:20 pm, Roy Smith [EMAIL PROTECTED] wrote: All somebody has to do to get at the private data is: #define private public # include MySecretClass.h #undef private Well, that shows the weakness of the C/C++ header files. The include directive merely does a simple text substitution,

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Larry Bates
Russ P. wrote: On Jun 2, 5:11 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: Russ P. [EMAIL PROTECTED] writes: I also realize, by the way, that Python allows a client of a class to define a new class member from completely outside the class definition. Obviously, that cannot be declared

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Matthieu Brucher
2008/6/5 Russ P. [EMAIL PROTECTED]: On Jun 5, 12:20 pm, Roy Smith [EMAIL PROTECTED] wrote: All somebody has to do to get at the private data is: #define private public # include MySecretClass.h #undef private Well, that shows the weakness of the C/C++ header files. The include

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread David
On Wed, Jun 4, 2008 at 2:54 PM, Roy Smith [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], Ben Finney [EMAIL PROTECTED] wrote: By definition, private functions are not part of the publicly documented behaviour of the unit. Any behaviour exhibited by some private component is seen

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Hrvoje Niksic
Russ P. [EMAIL PROTECTED] writes: By the way, my recollection is that in C++ access defaults to private if nothing is declared explicity. So normally the private declaration is unnecessary. If it is left out, your little trick won't work. How about #define class struct --

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Ben Finney
Roy Smith [EMAIL PROTECTED] writes: In article [EMAIL PROTECTED], Ben Finney [EMAIL PROTECTED] wrote: Then what you're really testing is the interactions of the push the button function with its external interface: you're asserting that the push the red button function actually uses

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
On Jun 5, 2:27 pm, Dennis Lee Bieber [EMAIL PROTECTED] wrote: On Thu, 5 Jun 2008 11:36:28 -0700 (PDT), Russ P. [EMAIL PROTECTED] declaimed the following in comp.lang.python: would need to use a mangled name to access private data or methods. But you will be using the name many times, you

Re: Why does python not have a mechanism for data hiding?

2008-06-05 Thread Russ P.
On Jun 5, 2:57 pm, Hrvoje Niksic [EMAIL PROTECTED] wrote: Russ P. [EMAIL PROTECTED] writes: By the way, my recollection is that in C++ access defaults to private if nothing is declared explicity. So normally the private declaration is unnecessary. If it is left out, your little trick won't

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Ben Finney
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] writes: On Wed, 04 Jun 2008 13:50:42 +1000, Ben Finney wrote: It seems you [alex23] have a different idea of what unit testing is for from me. For me it's about finding bugs where documentation and implementation disagree. Where documentation

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Antoon Pardon
On 2008-06-03, Lie [EMAIL PROTECTED] wrote: Python has an extremely good design because the BDFL doesn't just listen to everyone and create a product that tries to please everybody, no, he listens to those that have good ideas and tells the stupid ideas to go away and he applies a subjective

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Antoon Pardon
On 2008-06-03, sturlamolden [EMAIL PROTECTED] wrote: On Jun 2, 12:40 pm, Antoon Pardon [EMAIL PROTECTED] wrote: I think you completed missed the point. This is just a proof of concept thing. In a real example there would of course no Set en Get methods but just methods that in the course of

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Marc 'BlackJack' Rintsch
On Wed, 04 Jun 2008 15:55:38 +1000, Ben Finney wrote: Marc 'BlackJack' Rintsch [EMAIL PROTECTED] writes: On Wed, 04 Jun 2008 13:50:42 +1000, Ben Finney wrote: It seems you [alex23] have a different idea of what unit testing is for from me. For me it's about finding bugs where

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Antoon Pardon
On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: it makes sense to me to also test if they work as documented. If they affect the behaviour of some public component, that's where the documentation should be. As I said they are public themselves for someone. Isn't that

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread NickC
On May 26, 7:32 am, Joe P. Cool [EMAIL PROTECTED] wrote: I saw this don't need it pattern in discussions about the ternary if..else expression and about except/finally on the same block level. Now Python has both. if/else was added solely because people kept coming up with ways of embedding a

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread NickC
On May 26, 2:49 pm, Russ P. [EMAIL PROTECTED] wrote: I am also bothered a bit by the seeming inconsistency of the rules for the single underscore. When used at file scope, they make the variable or function invisible outside the module, but when used at class scope, the underscored variables

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Paul Rubin
NickC [EMAIL PROTECTED] writes: if/else was added solely because people kept coming up with ways of embedding a pseudo conditional inside expressions and writing buggy code in the process. All it really saves you in practice is a bit of vertical whitespace, so, no, you still don't need it -

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread NickC
On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes, you can live with it, and it does no harm, but you still want to get rid of it. With leading underscores, you

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread NickC
On May 25, 8:01 pm, Fuzzyman [EMAIL PROTECTED] wrote: Python was not really written with 'difficult' customers in mind ;-) True. It's extremely suited to what we do though.Minor difficulties like this are vastly outweighed by advantages. The difficulties are real though. It's interesting to

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread NickC
On Jun 4, 4:41 pm, Antoon Pardon [EMAIL PROTECTED] wrote: Guido has been known to change his mind, which is an admirabele quality, but it does show that at some point he rejected a good idea or accepted a bad idea. And sometimes the person that talked him into accepting the bad idea in the

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Ben Finney
Marc 'BlackJack' Rintsch [EMAIL PROTECTED] writes: On Wed, 04 Jun 2008 15:55:38 +1000, Ben Finney wrote: By definition, private functions are not part of the publicly documented behaviour of the unit. Any behaviour exhibited by some private component is seen externally as a behaviour of

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread NickC
On Jun 4, 9:24 pm, Paul Rubin http://[EMAIL PROTECTED] wrote: NickC [EMAIL PROTECTED] writes: if/else was added solely because people kept coming up with ways of embedding a pseudo conditional inside expressions and writing buggy code in the process. All it really saves you in practice is a

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread NickC
On Jun 4, 9:56 pm, Ben Finney [EMAIL PROTECTED] wrote: Those unit tests should *not*, though, exercise anything but the public API, otherwise they're breaking encapsulation. Their assertion should continue to be just as true after a refactoring of the internal components as before. Python

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Antoon Pardon
On 2008-06-04, NickC [EMAIL PROTECTED] wrote: On May 26, 7:32 am, Joe P. Cool [EMAIL PROTECTED] wrote: I saw this don't need it pattern in discussions about the ternary if..else expression and about except/finally on the same block level. Now Python has both. if/else was added solely

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Antoon Pardon
On 2008-06-04, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes, you can live with it, and it does no harm, but you still want

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread cokofreedom
But the leading underscore doesn't tell you whether it is your own private date, which you can use a you see fit, or those of someone else, which you have to be very carefull with. -- Antoon Pardon Well how is that different from public accessor and mutators of private variables? --

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Antoon Pardon
On 2008-06-04, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: But the leading underscore doesn't tell you whether it is your own private date, which you can use a you see fit, or those of someone else, which you have to be very carefull with. -- Antoon Pardon Well how is that different from

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Roy Smith
In article [EMAIL PROTECTED], Ben Finney [EMAIL PROTECTED] wrote: By definition, private functions are not part of the publicly documented behaviour of the unit. Any behaviour exhibited by some private component is seen externally as a behaviour of some public component. You know the

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Russ P.
On Jun 4, 4:29 am, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes, you can live with it, and it does no harm, but you

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread topher
On Jun 4, 2:58 pm, Russ P. [EMAIL PROTECTED] wrote: On Jun 4, 4:29 am, NickC [EMAIL PROTECTED] wrote: On Jun 4, 4:09 am, Russ P. [EMAIL PROTECTED] wrote: What is it about leading underscores that bothers me? To me, they are like a small pebble in your shoe while you are on a hike. Yes,

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Ben Finney
Roy Smith [EMAIL PROTECTED] writes: The only externally visible interface is pushTheButton(), yet you don't really want to call that during testing. What you do want to do is test that a random city really does get picked. Then what you're really testing is the interactions of the push the

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Hans Nowak
Lie wrote: On May 24, 9:14 pm, Fuzzyman [EMAIL PROTECTED] wrote: For example, at Resolver Systems we expose the spreadsheet object model to our users. It hasa public, documented, API - plus a host of undocumented internally used methods. We would really *much* rather hide these, because

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Marc 'BlackJack' Rintsch
On Wed, 04 Jun 2008 09:34:58 +, Antoon Pardon wrote: On 2008-06-04, Marc 'BlackJack' Rintsch [EMAIL PROTECTED] wrote: it makes sense to me to also test if they work as documented. If they affect the behaviour of some public component, that's where the documentation should be. As I

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Ethan Furman
Ben Finney wrote: Roy Smith [EMAIL PROTECTED] writes: The only externally visible interface is pushTheButton(), yet you don't really want to call that during testing. What you do want to do is test that a random city really does get picked. Then what you're really testing is the

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Ben Finney
Ethan Furman [EMAIL PROTECTED] writes: I must be missing something in this discussion. Perhaps it's the appropriate point of view. At any rate, it seems to me that any and every function should be tested to ensure proper results. I restrict that to every proper behaviour the system is

Re: Why does python not have a mechanism for data hiding?

2008-06-04 Thread Roy Smith
In article [EMAIL PROTECTED], Ben Finney [EMAIL PROTECTED] wrote: Then what you're really testing is the interactions of the push the button function with its external interface: you're asserting that the push the red button function actually uses the result from pick a random city as its

Re: Why does python not have a mechanism for data hiding?

2008-06-03 Thread Antoon Pardon
On 2008-06-03, Carl Banks [EMAIL PROTECTED] wrote: On Jun 2, 10:14 am, Antoon Pardon [EMAIL PROTECTED] wrote: On 2008-06-02, Carl Banks [EMAIL PROTECTED] wrote: Can't you look beyond the specific example? The GetX is just an example. Any local function of __init__ has access to hidden and its

  1   2   >