Importing "Modules"

JJ joacim at home.se
Wed Mar 22 10:36:05 CET 2000


Thanks, that helped!

BR
 Joacim

"Michal Bozon" <bozon at natur.cuni.cz> wrote in message
news:Pine.OSF.4.10.10003211613150.2319-100000 at prfdec.natur.cuni.cz...
> On Tue, 21 Mar 2000, JJ wrote:
>
> > 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
> ****************
>
> So Const.pyc or Constants.pyc?
> Maybe Constants.pyc
>
> Probably PYTHONPATH does not contain a Constants directory.
> - - - -
> import sys
> sys.path.append("c:/python/scripts/constants")
>
> import Constants
> ...
> ...
>
> Michal Bozon
>
>
> > -----------------------------------------------------------
> > # 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