Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

globals.py 647B

12345678910111213141516171819202122232425
  1. """Warnings about global statements and usage of global variables."""
  2. from __future__ import print_function
  3. global CSTE # [global-at-module-level]
  4. print(CSTE) # [undefined-variable]
  5. CONSTANT = 1
  6. def fix_contant(value):
  7. """all this is ok, but try not using global ;)"""
  8. global CONSTANT # [global-statement]
  9. print(CONSTANT)
  10. CONSTANT = value
  11. def other():
  12. """global behaviour test"""
  13. global HOP # [global-variable-not-assigned]
  14. print(HOP) # [undefined-variable]
  15. def define_constant():
  16. """ok but somevar is not defined at the module scope"""
  17. global SOMEVAR # [global-variable-undefined]
  18. SOMEVAR = 2