Question on Standard Types

John Roth newsgroups at jhrothjr.com
Sun Sep 7 19:18:57 CEST 2003


"hostmaster" <alpot at mylinuxsite.com> wrote in message
news:mailman.1062951612.13844.python-list at python.org...
> Hi,
>
> I'm quite new to Python and I am reading this book called 'Core Python
> Programming' by Wesley J. Chun.  I think that this is not a new book but
> I believe some of the points are still valid.
>
> There is this part in the book where it says:
>
> "In Python, standard types are not classes, so creating integers and
> strings does not involve instantiation".
>
> But later in the book, it talks about 'numeric objects' created when a
> numeric literal is assigned to a reference.
>
> So my question now is, if standard types are objects, shouldn't they
> have classes as well ? Isn't it that a class is the blueprint of an
> object? If they don't have a class to begin with, how are these objects
> created?

He's trying to make a fairly subtle point. At least, it's subtle until
you get into the nuts and bolts.

The point is that class instances are a single type, regardless of
the class. So while it's perfectly true to say what he did, it has
very little practical meaning unless you attempt to do an operation
on, say, an integer that depends on something that's unique to
an instance.

John Roth


>
> Thanks.
>
>
> Al
>






More information about the Python-list mailing list