Global variables - UnboundLocalError in Python

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

   This question already has an answer here:
    * /questions/41369408/how-to-change-a-variable-after-it-is-already-defined-in-python /questions/41369408/how-to-change-a-variable-after-it-is-already-defined-in-python 6 answers

Answers

http://docs.python.org/3.3/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python http://docs.python.org/3.3/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python

counter += 1

http://docs.python.org/3.3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value http://docs.python.org/3.3/faq/programming.html#why-am-i-getting-an-unboundlocalerror-when-the-variable-has-a-value

http://docs.python.org/3.3/reference/simple_stmts.html#the-nonlocal-statement http://docs.python.org/3.3/reference/simple_stmts.html#the-nonlocal-statement

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/9264763/unboundlocalerror-in-python

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils