|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
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
|
||||
|
||||
|
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. |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
||||
|
||||
|
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. |
|
#5
|
||||
|
||||
|
cheers guy iwas wondering why it flashed on the screen
|
|
#6
|
|||
|
|||
|
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. |
|
#7
|
||||
|
||||
|
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. |
|
#8
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Python Programming > newbie |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|