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

python - Writing Greek in matplotlib labels, titles -

c# - LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method -

Pygame memory leak with transform.flip -