Importing "Modules"
JJ
joacim at home.se
Tue Mar 21 03:55:55 EST 2000
Hi!
I have a lot of String contants and want them in a separate file. Then
import the file in nessesary scripts.
I have the scripts in directory C:\Python\Scripts\ and my contants in
C:\Python\Scripts\Contants\Const.pyc
How can I import 'Constants.pyc' in C:\Python\Scripts\Test.py ?
Constants.pyc
-----------------------------------------------------------
# Contants for PTC
strBil1 = "151001501"
strBil2 = "151001502"
strBil3 = "151001503"
strBil4 = "151001504"
strBil5 = "151001505"
-----------------------------------------------------------
Test.py
-----------------------------------------------------------
import constants
print "The car is: " + constants.strBil1
-----------------------------------------------------------
When I have them in the same directory I get:
'import exceptions' failed; using string-based exceptions
Exception occurred during event dispatching:
Traceback (innermost last):
File "C:\Python\Scripts\Test.py", line 3, in ?
ImportError: no module named constants
BR
Joacim
More information about the Python-list
mailing list