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

BartC bc at freeuk.com
Tue Jun 2 13:59:20 EDT 2015


On 02/06/2015 18:00, Steven D'Aprano wrote:
> On Tue, 2 Jun 2015 10:49 pm, BartC wrote:
>
>> On 02/06/2015 12:27, Steven D'Aprano wrote:

>>> In the programming language Java, *some* values are objects, and some
>>> values are not objects.
>>>
>>> In the programming language Python, *all* values are objects, in the
>>> general sense. That is what we mean by "Everything is an object".
>>
>> In a dynamically typed language such as Python, you need to be able to
>> deal with values consistently whatever their type, simply because you
>> can't tell what the types are from source code. (Not without a lot of
>> work which Python doesn't attempt, although RPython might do so.) Example:
>>
>>    print (a)
>>
>> a might be the int 42, or a it might be a million-element list. So both
>> are wrapped up as 'objects'.
>
> Again, this is not relevant. Javascript is dynamically typed, but some
> values are machine primitives and other values are objects. The interpreter
> keeps track of this at runtime.

Javascript primitives include Number and String.

What does Python allow to be done with its Number (int, etc) and String 
types that can't be done with their Javascript counterparts, that makes 
/them/ objects?

-- 
Bartc



More information about the Python-list mailing list