thmpsn....@gmail.com wrote: >> To be clear, python does not force you to lay out your code according to >> some strict object-oriented paradigm. But Python itself is still purely >> object-oriented, as is your script when parsed. > > But it's only a faking, and things such as inheritance and > polymorphism are implemented clumsily (actually I'm not even sure > about polymorphism). And of course, there are still no private > members.
How is it faking? The class of a function object is "function," which is of the metaclass "type." What more do you want? If Guido himself declared that functions are objects would you believe that? Or modules? Since a function object is an instance of the class "function" I don't see how you could inherit from it, and polymorphism has nothing to do with this either. Maybe what you are talking about is deriving a class from the class "function." Not sure if that's allowed, mainly because the language has defined a standard way of declaring a function (methods are functions too, of course), so creating a useful, derived function object would be difficult given how the syntax of the language works. Private members? I could stick add any attribute I wanted to a function object and ask that people treat it as private if I wanted to: def myfunc(): pass myfunc.__dict__['_private'] = 4 If you are insinuating that not forcing private attributes to be unaccessible by others (black box theory) is in somehow a violation of object-oriented semantics, think again. It's not. (There are no formal definitions of OO anyay, but wikipedia lists quite a few characteristics considered common to OO, and enforced private members is not one of them.) -- http://mail.python.org/mailman/listinfo/python-list