Python Language Variable Scope and Binding

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!


  • 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

Got any Python Language Question?