IDLE Python and Environment Variables

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tristan

    #1

    IDLE Python and Environment Variables

    Hello community:
    I post this because I could not find satisfactory answers in the posts
    generated by this nice group.
    I work on winXP. I have many little python applications in different
    folders, each application can share or not other objects located in the

    same or other folders.
    The way I work to use these applications is:
    1) For almost everyone, I execute a corresponding ".bat file" into

    which I define and/or include values for some "temporal"
    environment variables that let me find all the objects that the
    selected application uses. Sometimes I include in the .bat file the
    execution of the application, but generally I leave in a prompt status,

    ready to invoke python or some dos commands.
    2) When I close the command prompt window, there are no traces of
    my
    enviroment variables in my windows system (that is right). Only the
    default windows environment variables remain.

    I tried to do the same with the IDLE (and I imagine tha same occurs
    with Python command line), but I have the next problem:
    I can not find in IDLE (or another app?) the way to previously define
    and/or include automatically values for my "temporal" environment
    variables as I do in the .bat files. The use of Control Panel -System

    -Advanced is tedious to use as, my enviroment variables values are
    "temporal".
    Any advice, please???

  • Gabriel Genellina

    #2
    Re: IDLE Python and Environment Variables

    At Wednesday 10/1/2007 23:24, Tristan wrote:
    >1) For almost everyone, I execute a corresponding ".bat file" into
    >
    >which I define and/or include values for some "temporal"
    >environment variables that let me find all the objects that the
    >selected application uses. Sometimes I include in the .bat file the
    >execution of the application, but generally I leave in a prompt status,
    >
    >ready to invoke python or some dos commands.
    What kind of environment variables? Those used by Python itself, like
    PYTHONPATH? Or your own variables, like FOO_LOCATION=C: \My\Projects\Li b\Foo
    >2) When I close the command prompt window, there are no traces of
    >my
    >enviroment variables in my windows system (that is right). Only the
    >default windows environment variables remain.
    >
    >I tried to do the same with the IDLE (and I imagine tha same occurs
    >with Python command line), but I have the next problem:
    >I can not find in IDLE (or another app?) the way to previously define
    >and/or include automatically values for my "temporal" environment
    >variables as I do in the .bat files.
    So you write a .bat that:
    - defines some variables
    - calls your script.
    It appears that your variables are some kind of configuration - in
    this case it has more sense to put such configuration in another
    place, like a config file, and forget about environment variables.
    You can use the usual .ini Windows format and read it with
    ConfigParser. You can pass your script the name of the ini file to
    read - this would be the equivalent of using different .bat files to
    call the same script.
    This way it doesn't matter whether you invoke your application using
    python command line, or inside IDLE, or inside another environment.


    --
    Gabriel Genellina
    Softlab SRL






    _______________ _______________ _______________ _____
    Preguntá. Respondé. Descubrí.
    Todo lo que querías saber, y lo que ni imaginabas,
    está en Yahoo! Respuestas (Beta).
    ¡Probalo ya!


    Comment

    • Tristan

      #3
      Re: IDLE Python and Environment Variables

      Thanks Gabriel.
      What kind of environment variables? Those used by Python itself, like
      PYTHONPATH? Or your own variables, like FOO_LOCATION=C: \My\Projects\Li b\Foo
      I need to add to PYTHONPATH and other enviroment variables asked, for
      example, by DJANGO or other python products.
      It appears that your variables are some kind of configuration - in
      this case it has more sense to put such configuration in another
      place, like a config file, and forget about environment variables.
      You can use the usual .ini Windows format and read it with
      ConfigParser. You can pass your script the name of the ini file to
      read - this would be the equivalent of using different .bat files to
      call the same script.
      This way it doesn't matter whether you invoke your application using
      python command line, or inside IDLE, or inside another environment.
      I considered to use it, thanks!! Incidentally (beg your pardon if it
      sounds to ignorance), can I define Environment variables in a config
      file and then apply to my python program?

      Thanks!!!

      Comment

      • Gabriel Genellina

        #4
        Re: IDLE Python and Environment Variables

        At Thursday 11/1/2007 11:45, Tristan wrote:
        >I considered to use it, thanks!! Incidentally (beg your pardon if it
        >sounds to ignorance), can I define Environment variables in a config
        >file and then apply to my python program?
        Yes, read them from the config file and then use os.environ['name']=value
        See http://docs.python.org/lib/os-procinfo.html


        --
        Gabriel Genellina
        Softlab SRL






        _______________ _______________ _______________ _____
        Preguntá. Respondé. Descubrí.
        Todo lo que querías saber, y lo que ni imaginabas,
        está en Yahoo! Respuestas (Beta).
        ¡Probalo ya!


        Comment

        Working...