How to globalize vars ???

Miki Tebeka miki.tebeka at zoran.com
Sun Jan 11 18:36:36 CET 2004


Hello,

Warning: Fix not tested.

> def SSInit(SessionDir):
      global SSDefaultDir # FIX
>     SSLock()
>     try:
>       if SSDefaultDir.strip()=="":
> #       <-
> # UnboundLocalError: local variable 'SSDefaultDir' referenced before assignment
>          SSDefaultDir=SessionDir
>     finally:
>       SSUnlock()

> Why ? How to force python to module see his variable ?
By definition all new variables are local to their function.

HTH.
Miki



More information about the Python-list mailing list