Sie sind auf Seite 1von 1

###################### 11.

2 A first module
------------------------------- File mymath.py ------------------------------"""mymath - our example math module"""
pi = 3.14159
def area(r):
"""area(r): return the area of a circle with radius r."""
global pi
return(pi * r * r)
###################### 11.5 Private names in modules
------------------------------- File modtest.py ------------------------------"""modtest: our test module"""
def f(x):
return x
def _g(x):
return x
a = 4
_b = 2
###################### 11.7 Python scoping rules and namespaces
------------------------------- File scopetest.py -----------------------------"""scopetest: our scope test module"""
v = 6
def f(x):
"""f:
print
print
y = x
w = v
print

scope test function"""


"global: ", globals().keys()
"entry local:", locals()
"exit local:", locals()

Das könnte Ihnen auch gefallen