while 1 vs while True

Terry Reedy tjreedy at udel.edu
Wed Dec 15 16:27:19 EST 2004


> >>> import pdb
> >>> pdb.x = "Darn writeable module dictionaries"
> >>> from pdb import x
> >>> x
> >>>'Darn writeable module dictionaries'

> If Python really does behave that way, that bug should be fixed 
> immediately.

The fact that the attributes of Python modules, like those of classes (and 
functions and instances) are externally mutable is a design feature, not a 
bug.  (Call Python's dynamicity a design bug if you will, but that is 
different from a plain 'bug'.)

This allows, for instance, programs to have an in-memory blackboard module 
with across-module variables that all other modules can write to as well as 
read.  This design has been recommended several times on this list.  We 
would, of course, all agree that having modules arbitrarily poking each 
others attributes is a bad idea.  Indeed, that is the rationale for 
isolating all such pokes into a single blackboard module.

Terry J. Reedy






More information about the Python-list mailing list