[Python-3000] Types and classes

Guido van Rossum guido at python.org
Thu Apr 3 01:09:36 CEST 2008


No. types *have* a __dict__, but it's readonly.

Some type *instances* don't have a __dict__, but that's up to the
individual type.

All I really mean to fix is to standardize the terminology, especially
in repr().

On Wed, Apr 2, 2008 at 4:04 PM, Benjamin Peterson
<musiccomposition at gmail.com> wrote:
>
>
>
> On Wed, Apr 2, 2008 at 6:01 PM, Guido van Rossum <guido at python.org> wrote:
> > I don't recall proposing a name change. And I still don't see what
> > metaclasses have to do with it; I just mentioned them because 'type'
> > is both usable as a built-in function to access an object's class, and
> > as a metaclass (in fact it is the root metaclass).
> Ah. You were referring to allowing types to have __dict__ attributes, right?
> I misread and thought you wanted to rename.
>
>
> >
> >
> > On Wed, Apr 2, 2008 at 3:58 PM, Benjamin Peterson
> >
> >
> >
> > <musiccomposition at gmail.com> wrote:
> > >
> > >
> > >
> > > On Wed, Apr 2, 2008 at 5:51 PM, Guido van Rossum <guido at python.org>
> wrote:
> > > > I have no idea what you are saying here (and I did s/since/sense/ :-).
> > > Another lesson to me, that I should proofread my Python impulses: :P
> > > Especially because of that I think we should do that. list, dict, and
> set
> > > aren't metaclasses, so it would make sense to make that name change.
> > >
> > >
> > > >
> > > >
> > > >
> > > >
> > > >
> > > > On Wed, Apr 2, 2008 at 3:34 PM, Benjamin Peterson
> > > > <musiccomposition at gmail.com> wrote:
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > On Wed, Apr 2, 2008 at 5:20 PM, Guido van Rossum <guido at python.org>
> > > wrote:
> > > > > >
> > > > > > On Wed, Apr 2, 2008 at 3:03 PM, Amaury Forgeot d'Arc
> > > <amauryfa at gmail.com>
> > > > > wrote:
> > > > > > >  On Wed, Apr 2, 2008 at 11:57 PM, Paul Prescod
> <paul at prescod.net>
> > > wrote:
> > > > > >
> > > > > > >  >  But does anyone else find it odd that the types of some
> things
> > > are
> > > > > > >  >  classes and the classes of some things are types?
> > > > > > >  >
> > > > > > >  >  >>> type(socket.socket())
> > > > > > >  >  <class 'socket.socket'>
> > > > > > >  >  >>> type("abc")
> > > > > > >  >  <type 'str'>
> > > > > > >  >  >>> socket.socket().__class__
> > > > > > >  >  <class 'socket.socket'>
> > > > > > >  >  >>> "abc".__class__
> > > > > > >  >  <type 'str'>
> > > > > > >  >
> > > > > > >  >  In a recent talk I could only explain this as a historical
> > > quirk. As
> > > > > I
> > > > > > >  >  understand, it is now possible to make types that behave
> > > basically
> > > > > > >  >  exactly like classes and classes that behave exactly like
> types.
> > > Is
> > > > > > >  >  there any important difference between them anymore?
> > > > > > >
> > > > > > >  I can find one difference:
> > > > > > >  - types are written in C
> > > > > > >  - classes are written in Python
> > > > > > >
> > > > > > >  and there is a difference in behaviour:
> > > > > > >  most types don't have a writable __dict__, and you cannot add
> > > members.
> > > > > > >  classes are more flexible.
> > > > > >
> > > > > > That's more correctly described as the difference between built-in
> > > > > > types/classes and user-defined types/classes.
> > > > > >
> > > > > > I think it's still just a historical quirk; maybe we should bite
> the
> > > > > > bullet and fix this in py3k. (Still, 'type' and 'class' will both
> be
> > > > > > part of the language, one as a built-in function and metaclass,
> the
> > > > > > other as a keyword.)
> > > > > Especially because of that I think we should change. list, dict, and
> set
> > > > > aren't metaclasses, so it would make since to fix it.
> > > > > >
> > > > > >
> > > > > > --
> > > > > >
> > > > > > --Guido van Rossum (home page: http://www.python.org/~guido/)
> > > > > >
> > > > > >
> > > > > >
> > > > > >
> > > > > > _______________________________________________
> > > > > > Python-3000 mailing list
> > > > > > Python-3000 at python.org
> > > > > > http://mail.python.org/mailman/listinfo/python-3000
> > > > > > Unsubscribe:
> > > > >
> > >
> http://mail.python.org/mailman/options/python-3000/musiccomposition%40gmail.com
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Cheers,
> > > > > Benjamin Peterson
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > >
> > > >
> > > > --Guido van Rossum (home page: http://www.python.org/~guido/)
> > > >
> > >
> > >
> > >
> > > --
> > > Cheers,
> > > Benjamin Peterson
> >
> >
> >
> > --
> >
> >
> >
> > --Guido van Rossum (home page: http://www.python.org/~guido/)
> >
>
>
>
> --
> Cheers,
> Benjamin Peterson



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list