private variables/methods

Christopher Koppler klapotec at chello.at
Mon Oct 13 00:51:26 EDT 2003


On Sun, 12 Oct 2003 22:42:12 GMT, Alex Martelli <aleaxit at yahoo.com>
wrote:

>Sean Ross wrote:
>   ...
>> Hi.
>> I'm not sure I'm clear on what behaviour "import __current_module__" is
>> expected to have.
>
>Just like any other import, it binds the name to a module object -- except
>that it specifically binds said name to the module containing the function 
>that executes this import statement.  The use case is: deprecating the
>global statement.  Setting a global variable would instead use:
>    import __current_module__
>    __current_module__.thevariable = 23
>

Hmmm, asking naively: why not make global (or some better name, I
don't have any good ideas however) the self of the current module -
i.e. instead of

def fun():
  global x
  x = somevalue

or your import, you'd use

def fun():
  global.x = somevalue

And every module would set it's __global__ to itself by default...


Just a naive idea, of course...

--
Christopher




More information about the Python-list mailing list