Who am I: can a class instance determine its own name?

Alex Martelli aleaxit at yahoo.com
Thu Mar 15 07:30:10 EST 2001


"Tim Peters" <tim.one at home.com> wrote in message
news:mailman.984607702.5236.python-list at python.org...
> [Emile van Sebille]
> > Has locals changed so that it may be written to reliably?  My
> > documentation still warns:
> >
> > locals ()
> > Return a dictionary representing the current local symbol table.
Warning:
> > The contents of this dictionary should not be modified; changes may not
> > affect the values of local variables used by the interpreter.
>
> No, this has not changed.  As the docs say, writing to locals() is not
> allowed.
>
> and-more-likely-than-not-will-be-enforced-someday-too-ly y'rs  - tim

It *WOULD* be nice if all dictionaries had a "read-only" switch one
could throw to ensure no further modifications were accepted -- this
would make it trivial to enforce the semantics of 'locals' AND be
of similar use in similar application-level scenarios too.

(My dream is actually of a collection of bits in an attribute...:
    bit 1    no further modification/deletion of entries corresponding
                to already-existing keys
    bit 2    no addition of entries for keys that are not already present
    bit 4    no more changes to this attribute itself
and if all three were set, a dictionary might then become hashable,
and the world would suddenly be wonderful...:-).


Alex






More information about the Python-list mailing list