Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 26th, 2004, 08:41 AM
dave2k's Avatar
dave2k dave2k is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2003
Location: GB
Posts: 553 dave2k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 sec
Reputation Power: 10
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

Reply With Quote
  #2  
Old June 26th, 2004, 09:08 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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


Reply With Quote
  #3  
Old June 26th, 2004, 01:45 PM
Noah_C Noah_C is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 37 Noah_C User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 28 m 24 sec
Reputation Power: 9
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

Reply With Quote
  #4  
Old June 27th, 2004, 04:24 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #5  
Old June 27th, 2004, 06:55 AM
dave2k's Avatar
dave2k dave2k is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: May 2003
Location: GB
Posts: 553 dave2k User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 sec
Reputation Power: 10
cheers guy iwas wondering why it flashed on the screen

Reply With Quote
  #6  
Old June 27th, 2004, 10:54 AM
Noah_C Noah_C is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 37 Noah_C User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 28 m 24 sec
Reputation Power: 9
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.

Reply With Quote
  #7  
Old June 27th, 2004, 11:24 AM
netytan's Avatar
netytan netytan is offline
Hello World :)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2003
Location: Hull, UK
Posts: 2,537 netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level)netytan User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 2 Days 18 h 17 m 47 sec
Reputation Power: 68
Send a message via ICQ to netytan Send a message via AIM to netytan Send a message via MSN to netytan Send a message via Yahoo to netytan
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.

Reply With Quote
  #8  
Old June 27th, 2004, 12:07 PM
Noah_C Noah_C is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 37 Noah_C User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 28 m 24 sec
Reputation Power: 9
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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > newbie

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap