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

Ian Kelly ian.g.kelly at gmail.com
Tue Jun 2 15:50:11 EDT 2015


On Tue, Jun 2, 2015 at 1:31 PM, Jon Ribbens
<jon+usenet at unequivocal.co.uk> wrote:
> On 2015-06-02, Dr. Bigcock <dreamingforward at gmail.com> wrote:
>> On Tuesday, June 2, 2015 at 1:49:03 PM UTC-5, Jon Ribbens wrote:
>>> On 2015-06-02, Dr. Bigcock <dreamingforward at gmail.com> wrote:
>>> > It doesn't really do anything.  No one uses integers as objects.
>>> > (Any dissenters?)
>>>
>>> Yes. *Everyone* uses integers as objects. Containers such as
>>> lists and dictionaries and tuples etc contain objects. If
>>> integers weren't objects then you wouldn't be able to put them
>>> in containers (and you'd end up with Java).
>>
>> Sorry.  I meant "object" in the sense of OOP:  something you might
>> extend or make a derived class with.
>
> I'm not sure you get to define which properties of objects you want
> not to count.

Accepting for the sake of argument that "something to be subclassed"
is a reasonable definition of object, it should be pointed out that
anybody who works with bools in Python is using integers as objects.

The "Super Considered Harmful" essay also has a couple of examples of
subclasses of int, and even just googling "python subclass int"
demonstrates that there is plenty of interest in the subject.



More information about the Python-list mailing list