Question

  • Creator
    Topic
  • #2152911

    python programming language

    Locked

    by jairus kagondu ·

    i have been trying some programming using python 2.5.5 on windows but my problem is that i cant save ,retrieve and execute my codes…..to come up with a window,what am i missing?

All Answers

  • Author
    Replies
    • #2927432

      Clarifications

      by jairus kagondu ·

      In reply to python programming language

      Clarifications

    • #2927397

      Does this help you?. :)

      by Anonymous ·

      In reply to python programming language

      How to Save..

      > I tried but its not working. Here’s a code for sum of two numbers. Now
      > how do i save it?
      >
      >>>> #! /usr/bin/env python
      > …
      >>>> def sum(x,y):
      > … return x+y
      > …
      >>>> x=int(raw_input(‘Enter a number: ‘))
      > Enter a number: 35
      >>>> y=int(raw_input(‘Enter a number: ‘))
      > Enter a number: 7
      >>>> print ‘sum is’, sum(x,y)
      > sum is 42

      You *don’t* write your program inside Python; the interactive prompt is
      just for testing a few lines of code. Instead, use another program (a text
      editor) to create a file containing your source code, save it using a name
      like test1.py, and run it from a shell prompt using: python test1.py

      Retrieve ext. variables in python program.

      Trying to convert TCL code to python.

      Have a property file from where I read some VAR’s. Looks like this:
      EARPROJECT = sgs-procDist
      APPNAME = SGSProcedure

      In my TCL code I confirm the existence of the VAR = f.ex EARPROJECT by
      using code:

      if { ([info exists APPNAME] && [info exists STAGEDIR] && [info exists
      EARPROJECT] && [info exists EARDESTINATION]) } {
      Does anyone know and equalent way to confirm a Variable from the same
      property file using PYTHON code ???
      You can read it with the module ConfigParser

      how to run a code in python.

      The Python interpreter is usually installed as /usr/local/bin/python . Putting /usr/local/bin in your Unix shell’s search path makes it possible to start it by typing the command:

      python

      You may be able to check where the python is installed by typing “which python”.
      (Note. In the same way you can start CDAT typing “cdat” at a command line).

      You can put all your commands in a file with the extension ‘file_name.py’ and run it by
      typing:

      python file_name.py

      Note that there is a difference between “python file” and “python http://www2-pcmdi.llnl.gov/cdat/tips_and_tricks/python_tips/running_code.html
      ..................................

      Please post back if you have any more problems or questions.

Viewing 1 reply thread