Re: is python Object oriented??



Veerendra Ganiger wrote:
Python is not purely object oriented programming, because we can write
functions without any class.
You are right, predefined class attributes are available when we write or
execute a piece of python code without defining class, that means it's just
using objects for it's purpose. It does not mean its purely object oriented.

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.

This function without a class that you mentioned, is in fact an object
with attributes. You can pass a function around just like any other
object. Even calling a function is invoked like so:

myfunc.__call__(params)

So necessitating that code be inside a class has nothing to do with
object-oriented programming. Let's not forget that classes are
themselves objects (metaobjects in smalltalk parlance if I recall
correctly).

Now python does not have any way besides lambda expressions of creating
unbound function objects, but in practice this doesn't matter as I can
rebind names freely. I can still do:

a=myfunc
myfunc=some other expression or object

It all depends on implementation, I think even we can make "C" object
oriented with proper implementation.

Indeed, any code based on gobject libraries can be object-oriented in
design and function.
.



Relevant Pages

  • Re: How to create functors?
    ... Lambda expressions are, I believe, syntactically limited to a single expression -- no statements, like 'print' is in Python 2.x. ... exact answer you need may vary. ... I want to avoid using a def if possible. ...
    (comp.lang.python)
  • Re: is python Object oriented??
    ... execute a piece of python code without defining class, ... python does not force you to lay out your code according to ... Now python does not have any way besides lambda expressions of creating ... polymorphism are implemented clumsily (actually I'm not even sure ...
    (comp.lang.python)
  • Re: Whoa! Do Python and Lisp really have LAMBDA ?
    ... This is what the Haskell code eventually boild down to. ... > nowhere in Python there is a claim that lambda expressions are full fledged. ...
    (comp.lang.python)
  • Re: Whoa! Do Python and Lisp really have LAMBDA ?
    ... This is what the Haskell code eventually boild down to. ... > nowhere in Python there is a claim that lambda expressions are full fledged. ...
    (comp.lang.lisp)
  • Re: Learning Tkinter
    ... and how the command option is used to call the function callback. ... gui programming to see if the python programs I have written can be made ... search their computer for this file, execute the python code and then ... This is the meaning of the test on __name__: this magical variable is set to the string '__main__' if and only if the current script is the top-most one, i.e the one you ran python on. ...
    (comp.lang.python)