summaryrefslogtreecommitdiff
path: root/test/functional/globals.py
blob: 04bfd9521a2be7f39cf10f68b0ba6f39f8d08b18 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"""Warnings about global statements and usage of global variables."""

global CSTE  # [global-at-module-level]
print CSTE  # [undefined-variable]

CONSTANT = 1

def fix_contant(value):
    """all this is ok, but try not using global ;)"""
    global CONSTANT  # [global-statement]
    print CONSTANT
    CONSTANT = value


def other():
    """global behaviour test"""
    global HOP  # [global-variable-not-assigned]
    print HOP  # [undefined-variable]


def define_constant():
    """ok but somevar is not defined at the module scope"""
    global SOMEVAR  # [global-variable-undefined]
    SOMEVAR = 2