Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know about writing programs (using C) that have:

  1. Data values, that are manipulated. For example: integer, float values etc..

  2. functions (rules), by which data values are manipulated.

object is a coherent abstraction of representing something that encompass it's properties(data values) + interactions (functions) && processes (functions) that can manipulate those data values.

As a python beginner, I would like to know, why data values (like integers and floats) and processes(like functions) are considered objects?

From Guido's blog as mentioned below, I could find some relevant information but does not answer why?

The internal implementation of Python made this simple to do. All of Python's objects were based on a common C data structure that was used everywhere in the interpreter. Variables, lists, functions, and everything else just used variations of this one data structure---it just didn't matter if the structure happened to represent a simple object such as an integer or something more complicated such as a class.

How can a computational process(function) be an object as per any language design?

share|improve this question

closed as primarily opinion-based by Snowman, MichaelT, durron597, Ixrec, Bart van Ingen Schenau Nov 2 '15 at 11:31

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise.If this question can be reworded to fit the rules in the help center, please edit the question.

2  
What do you mean "why"? – jonrsharpe Feb 20 '15 at 10:46
2  
Because Python was designed that way. If you are not happy with this don't use Python. – Basile Starynkevitch Feb 24 '15 at 9:41
    
@WorldEngineer Is this query fit to re-open? – overexchange Feb 24 '15 at 11:34
3  
What is it about Guido's post you find unsatisfying? I think it answers the question; everything is an object in Python because it was easier to implement that way. I.e. There's no need for the Python interpreter to handle non-objects differently from objects. – Doval Feb 24 '15 at 12:56
1  
You're probably a bit too new to programming concepts to get it, but here goes - when the python just-in-time compiler compiles python code, it creates what is called an Abstract Syntax Tree. This tree represents all the tokens and the program structure. Abstracting more, it stores small trees(one for each statement) as a code block, and blocks can be called like any method. Blocks can also contain blocks. So a method points to a function object, which is a subclass of block. – Zeroth Feb 24 '15 at 23:26

If you have an object oriented language, then it should be normal and expected that every value is an object; you need special justification if that is not the case.

Update: it seems you're uncertain what the statement means, probably due to lack of contrast.

So let me provide contrast: in other languages, even those which are considered OO languages, some values are not objects. For example, Java has so-called "primitive types" like int, char and double. These are not objects, you cannot call methods on them and you cannot assign them to a variable of type Object. They need special treatmeant in many places, which is often a bit annoying.

The designers of Java chose to do this mainly for performance reasons, since objects typically have a certain overhead.

share|improve this answer
    
wiki says: An object is an abstract data type with the addition of polymorphism and inheritance. and Object orientation uses encapsulation and information hiding. So, Does python object support all these features? – overexchange Feb 20 '15 at 10:08
2  
Uh. That's wrong. Objects and Abstract Data Types are fundamentally different. See On Understanding Data Abstraction, Revisited by William R. Cook. In particular, Abstract Data Types, as the name implies, achieve abstraction using static types, but Python is untyped (in the strict mathematical type theoretic sense) or more precisely dynamically typed, so it cannot possibly support ADTs. It does however support objects, which are an alternative means of data abstraction. – Jörg W Mittag Feb 20 '15 at 10:47
    
@overexchange in Python, classes are also objects. – jonrsharpe Feb 20 '15 at 14:49
    
@JörgWMittag For the point in section 4.1 it says objects can be used to define data abstractions in a dynamically typed language.Objects do not depend upon a static type system;, If you consider a object created in python >>> x = 1 + 4j. This object is an instance of type class complex(may be at runtime). So, type class complex is defining data abstraction and object depend upon type system in dynamic language as well. class complex is an ADT. How class complex is represented by python interpreter is an abstraction to python programmer. am I correct? – overexchange Feb 20 '15 at 15:06
3  
@Doval (and Jörg): Your responses here regarding objects/classes vs. ADTs are enlightening in a very ivory-tower-y type-system-theorist-y way, but are confusing for an OOP-newbie. A dynamically typed language is only unityped statically, but this is not a valid or useful observation during runtime. Of course complex is a (concrete) type, which is represented by a builtin class in Python. Classes are a kind of data abstraction, and they define a new type, which is all that matters for now. Interfaces aren't necessarily objects, and classes aren't automatically ADTs, but both are abstractions. – amon Feb 24 '15 at 22:34

Not the answer you're looking for? Browse other questions tagged or ask your own question.