Really stupid question regarding PEP 252 and type/class unification

Terry Reedy tjreedy at home.com
Wed Aug 22 20:58:42 EDT 2001


"Russell Turpin" <russell_turpin at hotmail.com> wrote in message
news:8a12e538.0108221144.5b74df26 at posting.google.com...
> Let me begin with a caveat: I am zonked out on cold drugs.
> My reading of the PEP, and writing of this post, might
> suffer because of this. Throwing caution to the wind,
> here's my stupid question: What is the name (if any) of a
> type's (now class's) value attribute?

1. Types are still types and not classes.

2. Think of an object's value as its (unnamed) default attribute.  IE,
its the value you get if you do not specify a named attribute.  Note
that this is just as true of classes and instances.

def c(): pass
i = c()
print c,i

The value of c and i are the class and instance object, or, if you
will, the set of attributes, rather than any one in particular.

> Let me explain.
> Suppose I create an integer:
>     spam = 3
> The variable "spam" is an Integer, "Integer" is now a class
(unification, right?),

again, wrong.

> so there should be *some* attribute
> of the class Integer, lets call it __myval__, such that:
>
>     spam.__myval__ == 3
> And, in fact, writing "spam" in most assignments and tests
> should just be a shorthand for "spam.__myval__". Further,
> "__myval__" should be in Integer.__dict__, so that
> introspection works with it as with other attributes.

3. Object.__dict__ is a named attribute of Object that does *not*
appear in Object.__dict__.  c.__bases__ and i.__class__ also do not
appear in their __dicts__

> Does this make any sense? Or should I swear off cold meds
> when posting to comp.lang.python?

This pep and the next can make one's head spin even without cold meds.

Terry J. Reedy






More information about the Python-list mailing list