[Tutor] Python Question

Ole Jensen learning.python at dbmail.dk
Thu Sep 11 23:53:56 EDT 2003


> Hey. Im curretnly trying to learn Pyton... I saw the archive with A LOT of
> questions & answers. I have a question... As I said, I just started. I
began
> to read the 'Python for non-programers' tutorial, reached about chapter 8
> and stopped. It began to be very hard and confusing, and went on too fast.

If you find some topics hard in one tutorial, I would suggest trying looking
through another tutorial to see if you can find some different angles to the
topic you are having trouble with.
I guess you've already seen this site, but it doesn't hurt posting it again
;-) http://www.python.org/topics/learn/non-prog.html


I
> was wondering how I can upload my Python Programs online, and how will
> people see them. Also if I can make it a file evryone can see... I mean,
can
> computers who dont have Python installed can view me programs?

are you making a cgi script (or similar) or do you just want to let people
see and download your programs? If the latter: Then you can upload your
python programs just like a normal file, the browser (Internet Explorer)
will then open the file as if it was a normal txt-file and display the
contents. You could compress the files to a .zip which when the user clicks
the link it will automatically download the file instead of displaying it.

I have my own (small) archive on the net:
http://www.dbhome.dk/learningtoprogram/programs.html

You should be aware that if you upload the files as is, IE and possibly
others can corrupt the files by inserting html-code into the script.


And a small
> question: When I run the finished program, it quits and closes window if
it
> has nothing to do. For example if my program is just
>
> print "Hello, World!"
>
> it would open it for half a second and immediatly close the window... What
> to do? :)

then you will need to run the program in idle, or...
As you say "it close if it has nothing to do", you need to get it to wait
for something, maybe put an input() at the end or make a quit-loop as I call
it, building on your example:
quit = 1
while quit == 1:
    print "Hello World!"
    quit = input("press '1' to print again?")

Which agreed is a bit overkill here, but if you were to test several
different things in your script, its usefull instead of re-running the
program.





More information about the Tutor mailing list