Dynamic Dictionary Creation

Carl Banks imbosol at vt.edu
Fri Dec 6 23:18:32 EST 2002


Bengt Richter wrote:
> On Fri, 06 Dec 2002 11:37:07 -0700, Bob van der Poel <bvdpoel at kootenay.com> wrote:
>>I suppose I could make the table global and avoid this?
>>
> Yes, but if the table is only used in the function, that's not nice.
> There are several alternatives you could use.


I wouldn't totally agree with this.  Data that never changes ought to
be global.

Some languages allow you to define data that exists globally, but has
only local scope (for example, in C you can use "static" declarations
inside a function).  Whenever you can do this, I agree it's nicer to
put it inside the function.  But because you can't in Python, I think
it's "nicest" to just make it global.  (Not necessarily fastest.)

Besides, most of the good reasons not to use globals don't apply when
the data never changes.


-- 
CARL BANKS



More information about the Python-list mailing list