Mailing List Archive

class static vs. module global
I have a module aC, which conveniently holds a class aC. During some
recent changes, I needed to share information across class instances.
Primarily to localize things, I elected to store the information in the
class. Anyone want to share opinions on why I should instead have used
a module global variable? Or perhaps a different approach?

(Some additional information: instances of aC get invoked by aQ; with
the exception of two methods, aQ knows nothing about the actual workings
of aC, so storing the info in aQ would be a bad idea. If it helps any,
the information I'm storing in aC is essentially a cache that gets
flushed regularly. Also, I was trying to preserve the structure of
existing code as much as possible to make testing and re-integration
easier.)
--
--- Aahz (@netcom.com)

Hugs and backrubs -- I break Rule 6 <*> http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het

Javascript: The 90s incarnation of the Commodore 64 Sprite -- SJM
class static vs. module global [ In reply to ]
[Aahz Maruch]
> I have a module aC, which conveniently holds a class aC. During some
> recent changes, I needed to share information across class instances.
> Primarily to localize things, I elected to store the information in the
> class. Anyone want to share opinions on why I should instead have used
> a module global variable? Or perhaps a different approach?

There's no prohibition, either technical or cultural, against using class
data in Python. Thoroughly appropriate! It's "class static" *methods* that
get you in trouble -- but that's all in the FAQ.

class-data-is-classy-ly y'rs - tim