Variable Scope and Binding

Download python eBook

Syntax

  • global a, b, c
  • nonlocal a, b
  • x = something # binds x
  • (x, y) = something # binds x and y
  • x += something # binds x. Similarly for all other "op="
  • del x # binds x
  • for x in something: # binds x
  • with something as x: # binds x
  • except Exception as ex: # binds ex inside block

Related Examples

Stats

163 Contributors: 8
Monday, July 31, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook