gvsig-scripting / org.gvsig.scripting / trunk / org.gvsig.scripting / org.gvsig.scripting.app / org.gvsig.scripting.app.mainplugin / src / main / resources-plugin / scripting / lib / pylint / test / functional / globals.py @ 745
History | View | Annotate | Download (647 Bytes)
1 |
"""Warnings about global statements and usage of global variables."""
|
---|---|
2 |
from __future__ import print_function |
3 |
|
4 |
global CSTE # [global-at-module-level] |
5 |
print(CSTE) # [undefined-variable]
|
6 |
|
7 |
CONSTANT = 1
|
8 |
|
9 |
def fix_contant(value): |
10 |
"""all this is ok, but try not using global ;)"""
|
11 |
global CONSTANT # [global-statement] |
12 |
print(CONSTANT) |
13 |
CONSTANT = value |
14 |
|
15 |
|
16 |
def other(): |
17 |
"""global behaviour test"""
|
18 |
global HOP # [global-variable-not-assigned] |
19 |
print(HOP) # [undefined-variable]
|
20 |
|
21 |
|
22 |
def define_constant(): |
23 |
"""ok but somevar is not defined at the module scope"""
|
24 |
global SOMEVAR # [global-variable-undefined] |
25 |
SOMEVAR = 2
|