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

c# - Roxy file manager in MVC doesn't accept session path -

php - proc_open Too many open files in long running Symfony Console app -

c# - Show a huge number of data in DevExpress GridView -