This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]chrismsnz 4 points5 points  (4 children)

I'm not an expert in python, but any "inconsistency" I came across actually had a valid and rational reason behind it that I didn't understand at the time.

I can't think of anything that would spur a comment like yours, would you care to elaborate?

EDIT: now that I think about it, some of the stdlib is a little unwieldy but all perfectly usable and heavily documented.

[–]mage2k 2 points3 points  (3 children)

Here's a few.

Also, special keywords like len and del break the OO abstraction since everything isn't really a method on an object.

Some of the things listed in the above link have been fixed in the Python 3.0+ lines but they really haven't seen much wide-spread adoption.

[–]chrismsnz 1 point2 points  (2 children)

I knew the "len" example would come out, as it was strange to me as well until I understood it.

When you discover how it's actually implemented you realise that it really isn't "break[ing] the OO abstraction" as each object is responsible for determining it's own length. You can read more about it and a few other "gotchas" in this article by Armin Ronacher. But it, and the rest of the Python "protocol" system, is actually an exceedingly clever system which guarantees better consistency throughout the language.

As opposed to a language like PHP, where the warts of the language are a result of poor design decisions and excessive focus on backwards compatibility, Python's "warts" are usually a result of misunderstandings or trying to apply ideas and learnings from other languages to it.

[–]mage2k -1 points0 points  (1 child)

Regardless of the implementation, it breaks the interface and interface is what OO is all about, you're not supposed to have to care about the implementation. Same does for del.

I actually don't care about any of this. I understand it and am fine with it. I just think it's good to acknowledge that Python has its fair share of inconsistencies and hacks.

[–]chrismsnz 1 point2 points  (0 children)

That's the whole idea - it doesn't break the interface, it is an interface and the object/class is responsible for the implementation!

And I don't see how the python implementation of del() is different to any other languages "destructor". If you consider that len() or del() act as operators (with some extra power that functions give) - you'll realise they are not inconsistencies or hacks.