Steven D'Aprano a écrit :
On Thu, 22 Jan 2009 19:10:05 +0000, Mark Wooding wrote:

Steven D'Aprano <st...@remove-this-cybersource.com.au> writes:

On Thu, 22 Jan 2009 15:12:31 +0100, Bruno Desthuilliers wrote:
Steven D'Aprano a écrit :
But if you have free access to attributes, then *everything* is
interface.
Nope.
How could anyone fail to be convinced by an argument that detailed and
carefully reasoned?
Well, your claim /was/ just wrong.  But if you want to play dumb: the
interface is what's documented as being the interface.

But you miss my point.

We're told Python doesn't have private attributes.

Yes.

We're told that we're allowed to "mess with the internals",

Given that we're willing and able to cope with possible consequences.

we're *encouraged* to do so

Certainly not.

Python gives you the freedom to do so, and any suggestion that freedom might be reduced even a tiny bit is fought passionately.

Won't comment on this.

When people ask how to implement private attributes, they're often told not to bother even using single-underscore names.

"often" ? Not as far as I can tell. I think you're confusing this with the advice to not use getters/setters for no good reason, given Python's support for computed attributes - which is not exactly the same thing.

When it is suggested that Python should become stricter, with enforced data hiding, the objections come thick and fast: people vehemently say that they like Python just the way it is, that they want the ability to mess with the internals.

Indeed. There's no shortage of B&D languages, and well, Python is OSS, so if you want a B&D Python (now that's an oxymoron), please feel free to implement it. But by all mean, leave my favorite language alone. Thanks.

You even argued that you disliked data structures implemented in C and preferred those written in Python because you have more ability to mess with the private attributes.

In context, I had just mentioned that lists' internals were inaccessible from Python code. I neglected to give an example at the time, but a good example is the current length of the list. Consider the experience of Microsoft and Apple.

Yes, two great examples of freedom champions.

No matter how often they tell people not to mess with the internals, people do it anyway, and always believe that their reason is a good reason.

And who are *you* to pronounce any judgement about that ?

And Python culture encourages that behaviour (albeit the consequences are milder: no buffer overflows or core dumps).

Add to that the culture of Open Source that encourages reading the source code.

Indeed. A *very* good thing FWIW.

You don't need to buy a book called "Undocumented Tips and Tricks for Python" to discover the internals. You just need to read the source code.

Exactly.

And then you have at least two places in the standard library where _attributes are *explicitly* public:

http://bugs.python.org/issue3152

Given this permissive culture, any responsible

For your personal definition of "responsible".

library writer must assume that if he changes his so-called "private" attributes, he will break other people's code.

You still don't get the point. If someone's code breaks because he messed with my implementation code, then *he* is responsible. The contract is very clear : "warranty void if unsealed".

In principle it could break just as much code as if he didn't even bother flagging them with a leading underscore, which is probably why many people don't even bother with _names.
>
In other words, if you make it easy for people to mess with your internals, if you have a culture that allows and even encourages them to mess with your internals, then you don't have internals. Everything is de facto public.


Now that you've exposed your opinions, let's face reality (I mean, *facts*): Python developpers very rarely mess with implementation, usually do so for very good (and documented) reasons, and from what I've seen usually tend to get in touch with the library author to explain their case and find a better solution.

Funny enough, it looks that the more you treat programmers as responsible, normally intelligent adult person, the more they tend to behave as such. And the other way around, too.

Now, you comprehensively exposed your personnal distaste for Python's and more generally OSS philosophy. So I can only - as I already did way before in this thread - wonder *why* are you using Python ?

I mean, is it because your bosses forces you to do so ? If yes, then, I'm truly sorry for you - I sometimes have to work with languages I really dislike so I can feel your pain (but OTHO, I never complained on these languages newsgroups about how wrong they were nor how they should IMHO be).

Else, well, I just don't get the point. What you are fussing about are fundamental design choices (and philosophic points) that are well known, explained, advertized, etc. - and are really not likely to change anytime soon.
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to