Replace a module variable with a function call

gabriel.becedillas at gmail.com gabriel.becedillas at gmail.com
Mon Feb 6 14:19:53 EST 2006


There are modules (like os) that define some stuff that depends on the
platform (for example linesep). This platform dependent constants gets
their values assigned when the module gets loaded, but in our
application, different threads might run on different computers (by
proxying syscalls).. and we need to calculate that value every time the
constant gets referenced. We have a slightly modified version of
python's distro to accomplish this.

It sort of a design problem, like not exposing member variables of a
class to avoid breaking clients, and use an accesor function instead.

So.. it doesn't depend on the phase of the moon.. it depends on the
architecture of a host.
I can write ten million examples of functions that doesn't depend on
arguments to calculate a dynamic value, but since you couldn't figure
that out by yourself.. I'm not going to waste my time with more
examples coz probably you won't understand them either.




More information about the Python-list mailing list