From 1de75ffde681eba43d48a1caaa8dc7a7731741cd Mon Sep 17 00:00:00 2001 From: Andrew Gartland Date: Fri, 4 Sep 2015 12:47:31 -0700 Subject: [PATCH] Trying to figure out where to define package-wide constants. --- shablona/__init__.py | 4 ++++ shablona/constants.py | 2 ++ shablona/shablona.py | 10 ++++++++++ 3 files changed, 16 insertions(+) create mode 100644 shablona/constants.py diff --git a/shablona/__init__.py b/shablona/__init__.py index 1c260fc..3f2c121 100644 --- a/shablona/__init__.py +++ b/shablona/__init__.py @@ -1,2 +1,6 @@ +#from .constants import * +CONSTANT1 = 5 +CONSTANT2 = 'i am constant' + from .shablona import * from .version import __version__ \ No newline at end of file diff --git a/shablona/constants.py b/shablona/constants.py new file mode 100644 index 0000000..1177f54 --- /dev/null +++ b/shablona/constants.py @@ -0,0 +1,2 @@ +CONSTANT1 = 5 +CONSTANT2 = 'i am constant' \ No newline at end of file diff --git a/shablona/shablona.py b/shablona/shablona.py index 5974e5f..e93bf20 100644 --- a/shablona/shablona.py +++ b/shablona/shablona.py @@ -4,6 +4,16 @@ from scipy.special import erf import scipy.optimize as opt +from shablona import CONSTANT1, CONSTANT2 + +def print_constants(): + """ + Function that prints the constants defined by the package. + This is a demonstration of the proper way to define package-wide + constants and then use them throughout the package.""" + + print 'CONSTANT1: %s' % CONSTANT1 + print 'CONSTANT2: %s' % CONSTANT2 def transform_data(data): """