Everything is an object in python - object class and type class

Marko Rauhamaa marko at pacujo.net
Tue Jun 2 09:13:23 EDT 2015


BartC <bc at freeuk.com>:

> If you define 'object' in a certain way (eg. as boxed, tagged data),
> then it follows that some values don't need to be objects.

The word "object" really barely carries any meaning -- that's the point.
It's a Latin-based synonym of the Germanic "thing."

To say that everything is an object in Python simply means that the same
set of concepts applies to all data. The main distinguishing feature
between Python objects is mutability.

The utmost abstraction of everything into an object is the pinnacle of
understanding. The question is, should a beginning Python programmer
start the climb from the summit or from the root of the mountain. IOW,
does it help to start the Python journey by learning that numbers are
objects, given that the language gives lots of special treatment to
numbers (as well as strings, lists and functions, for example)?

I would imagine that the gentlest route to Python programming starts
without talking much about objects at all. Leave the discussion about
numbers as objects till after, say, multiple inheritance has been
covered. Then, things like strings as objects and regular expression
match objects can be brought in naturally, and expressions like

   ','.join(person.name
            for person in persons
            if person.is_underage())

no longer defy comprehension.


Marko



More information about the Python-list mailing list