Unbound variable in python -


I'm trying to create a toy singleton in Python for learning the language and simultaneously running into a problem. I am declaring such a class.

  class error logger: #include which provides logging in file instance = a df getInstance (): # Our singleton " Constructor "for example no one is: print" foo "  

when I

  file "/ home / pal / call    Projects / Space / SRC / Error Laggar ", line 7, if there is no example in getInstance: unbound local error: local variable 'example' referenced before assignment   

what's happening here , Should be assigned statically as an example? What would be the right way to do this?

This is a static variable in the form of the ErrorLogger prefix. Class error: Homeless: # Singleton which provides a file instance = any logging @staticmethod def getInstance (): # If our singleton "constructor" error logger .instance is none: print "foo"

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -