Thread: newbie

    #1
  1. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2003
    Location
    GB
    Posts
    553
    Rep Power
    12

    newbie


    i downloaded python, and no how to use it interactively, but how do i write a basic hello world script in windows, and get this to execute - it doesnt say in the official tutorial -cheers
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Wack open notepad or any other text editor and type..

    Code:
    #!/usr/bin/env python
    
    print 'hello world'
    The first line is technically not needed on Windows but it is a good practice to adopt if you ever plan to do any CGI or run a script on *nix.

    And to run this program simply save it as a text document with a .py extension and double click on this file .

    Also check out these links:

    http://www.python.org/doc/Intros.html
    http://www.hetland.org/python/instant-hacking.php

    Welcome to the Python community,

    Mark.
    programming language development: www.netytan.com Hula

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    11
    If you run it in a windows enviroment you are going to see it flash on the screen...

    So what I do is have C:\Python\folder hold all my Python stuff...
    and then type the following.

    cd C:\Python\folder
    helloworld.py
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Another way to get around this anoying problem is to add 'raw_input()' to the end of your files . Its a bit of a hack but very handy!

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2003
    Location
    GB
    Posts
    553
    Rep Power
    12
    cheers guy iwas wondering why it flashed on the screen
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    11
    Yeah, thanks for the little hack. I knew something like that would work, but always program in a text editor and test in the command prompt so I've never had a need for that.

    Thanks again!

    Anyone know of a way to change that in windows ? Becuase it does that with ipconfig and such as well. It's rather a pain.
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Not of the top of my head though i imagine this could be done by altering site.py, which is loaded when Python starts. Something you would have to mess around with since i dont have Python right now .

    One thing you should remember when altering a Python installations properties is that if anyone else runs your program they will not get the same results i.e. in this case where the console Window would stay on screen for you, other users would see if flash up and disapper.

    Have fun,

    Mark.
    programming language development: www.netytan.com Hula

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    37
    Rep Power
    11
    oh, I meant inside of windows. So if I ran a bash program or ipconfig or anything like that it just wouldn't flash up there.

    Oh, another thing the dave2k could do is create a bash program that when he double clicked it, it would load the folder he saved all this python stuff too.

IMN logo majestic logo threadwatch logo seochat tools logo