how to run a python script

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • selvanthiru
    New Member
    • Dec 2006
    • 7

    how to run a python script

    please tell me where i should type a python script,i.e a program and how can i run it in the idle help me please
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by selvanthiru
    please tell me where i should type a python script,i.e a program and how can i run it in the idle help me please
    IDLE is a good editor for getting started. Many of use use it, still.
    Run IDLE from the menu: Start->Programs->Python 2.x-> IDLE (Python GUI).
    In the File menu choose New Window.
    Write a program ie script like
    Code:
    print "hello"
    Save the file someplace that makes sense.
    From the Run menu, choose Run Module F5.

    That's it! Have fun and keep posting.

    Comment

    • selvanthiru
      New Member
      • Dec 2006
      • 7

      #3
      how to run a python script

      please tell me were should i type a script notepad or idle then where to save it ,
      then how to run it in command line and idle also tell me the same for linux please

      Comment

      • bartonc
        Recognized Expert Expert
        • Sep 2006
        • 6478

        #4
        Originally posted by selvanthiru
        please tell me were should i type a script notepad or idle then where to save it ,
        then how to run it in command line and idle also tell me the same for linux please
        On windows you can save it anywhere that you want to.
        On Linux the first line must look something like
        #! python
        But I'm not sure about that.

        Comment

        • bartonc
          Recognized Expert Expert
          • Sep 2006
          • 6478

          #5
          selvanthiru, welcome to the python forum at TheScripts Developer Network.

          What you had done was "double post". Two threads with the same topic. I have merged the two threads into one.

          Comment

          • true911m
            New Member
            • Dec 2006
            • 92

            #6
            Originally posted by bartonc
            On windows you can save it anywhere that you want to.
            On Linux the first line must look something like
            #! python
            But I'm not sure about that.
            #!/usr/bin/env python

            Comment

            • bartonc
              Recognized Expert Expert
              • Sep 2006
              • 6478

              #7
              Originally posted by true911m
              #!/usr/bin/env python
              Thanks, Mark. I won't forget it.

              Comment

              • dshimer
                Recognized Expert New Member
                • Dec 2006
                • 136

                #8
                Just in case this information is situation specific, I am running python 2.5 on windows and use PythonWin as my editor.
                Along the thoughts of where to save scripts and modules. I just create a directory for all my python stuff, then put it in the python search path by placing the full name of the directory in a file with a .pth extension in the python root directory (file can have any name, just needs that extension). That way wherever I am working, or when loading a script into pythonwin, python knows to look in that directory.

                Comment

                Working...