By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,689 Members | 1,123 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,689 IT Pros & Developers. It's quick & easy.

3 Simple Questions About Python/IDLE

P: n/a
1) why don't python / idle use numbered lines in their scripting, like
basic? how do you keep track of large batches of code without them?

2) in IDLE, how do you save a program such that it can be run, say from
windows the "run" function?

3) are most of you doing your script editing in IDLE or something more
fully featured?

4) how are you importing previously written blocks of code into your
code? cut and paste? what is the best way to organize snippets of
code?

thanks, peeps

Sep 7 '06 #1
Share this Question
Share on Google+
14 Replies


P: n/a
Omar wrote:
1) why don't python / idle use numbered lines in their scripting, like
basic? how do you keep track of large batches of code without them?

2) in IDLE, how do you save a program such that it can be run, say from
windows the "run" function?

3) are most of you doing your script editing in IDLE or something more
fully featured?

4) how are you importing previously written blocks of code into your
code? cut and paste? what is the best way to organize snippets of
code?

thanks, peeps
1) Python is very different from what you expect being experienced in
programming with Basic. My recommendation: don't hesitate to take the
time to read the Python manual.
2) Double click on saved Python script (hope you are able to save a
file? Haven't you detected that you can edit and run a file in IDLE?)
3) Plain text editor or IDLE are good. For more see Python website -
there are plenty options to choose from.
4) using 'import' (see recommendation in 1))

Claudio Grondi
Sep 7 '06 #2

P: n/a
thanks

Sep 7 '06 #3

P: n/a
thanks.

i have saved and double clicked as suggested. when I save and double
click a simple "hello program", the b&w python shell briefly comes up,
then disappears. is this how it should work?

Sep 7 '06 #4

P: n/a
Omar schrieb:
thanks.

i have saved and double clicked as suggested. when I save and double
click a simple "hello program", the b&w python shell briefly comes up,
then disappears. is this how it should work?
Yes. because when your program terminates, the shell terminates. Or
would you prefer it sticking around, cluttering screen space?

If you want it to stay, make your program require a key-press in the
end. something like this:

raw_input("press return")
Diez
Sep 7 '06 #5

P: n/a
Omar wrote:
thanks.

i have saved and double clicked as suggested. when I save and double
click a simple "hello program", the b&w python shell briefly comes up,
then disappears. is this how it should work?
Yes, that is how it should work. Program is doing what you
told it to. print "hello program" and exit (which closes the window).
If you want it to pause put something after the print like:

t=raw_input('Hit return to continue')

This way the program will pause until you hit return.

Good luck.

-Larry Bates
Sep 7 '06 #6

P: n/a
thank you genteman.

however, its not working :(

I resaved it, but same thing.

Sep 7 '06 #7

P: n/a
Omar wrote:
thank you genteman.

however, its not working :(

I resaved it, but same thing.
Please post some code so we can actually do something more than
read your mind. You can also run the program from a shell
instead of from idle to see what happens.

-Larry Bates
Sep 7 '06 #8

P: n/a
sure...
>>print "hello world"
hello world
>>t=raw_input('Hit return to continue')
I'm saving it as "helloworld11", then double clicking the icon I saved
it as.

Sep 7 '06 #9

P: n/a
okay...

I got to work using the SCITE editor with

print "hello world" # here we are once again
raw_input("press return")

cool!

Sep 7 '06 #10

P: n/a
Omar,

The '>>>' were causing the problem I would guess. Those are the
interactive interpreter's prompts, not python. Saving a python session
like that is a starting place for creating code, not the finished
product.

You might also want to save the file as "helloworld11.py" before double
clicking it.

Again, these problems indicate that you're not ready to even start
coding until you've read a good intro text.

John Purser

On Thu, 2006-09-07 at 09:11 -0700, Omar wrote:
okay...

I got to work using the SCITE editor with

print "hello world" # here we are once again
raw_input("press return")

cool!
Sep 7 '06 #11

P: n/a
I'm working through a tutorial,
http://swaroopch.info/text/Byte_of_Python:Control_Flow, and I sorta
can't get through the tutorial without overcoming these little
speedbumps. This is why I'm asking these questions.

Sep 7 '06 #12

P: n/a
On 2006-09-07, Dennis Lee Bieber <wl*****@ix.netcom.comwrote:
On 7 Sep 2006 06:53:44 -0700, "Omar" <ou*************@hotmail.com>
declaimed the following in comp.lang.python:
>1) why don't python / idle use numbered lines in their
scripting, like basic? how do you keep track of large batches
of code without them?

Because BASIC was created in the days of paper teletypes with
minimal editors. In BASIC, you would correct a line by retyping it with
the line number and the interpreter was responsible for "reordering" the
lines in memory. You could actually type a program in from last line to
first (ie, upside down) and it would run.

NO other language that I know of uses line numbers to control
source code order. Heck, Visual BASIC doesn't use line numbers
either (I don't recall if AmigaBASIC required them either).
(Nope.)

--
Neil Cerutti
Sep 7 '06 #13

P: n/a
Dennis Lee Bieber wrote:
On 7 Sep 2006 06:53:44 -0700, "Omar" <ou*************@hotmail.com>
declaimed the following in comp.lang.python:

>>1) why don't python / idle use numbered lines in their scripting, like
basic? how do you keep track of large batches of code without them?

Because BASIC was created in the days of paper teletypes with
minimal editors. In BASIC, you would correct a line by retyping it with
the line number and the interpreter was responsible for "reordering" the
lines in memory. You could actually type a program in from last line to
first (ie, upside down) and it would run.

NO other language that I know of uses line numbers to control source
code order. Heck, Visual BASIC doesn't use line numbers either (I don't
recall if AmigaBASIC required them either).
Well, there was Focal. Focal used floating-point line numbering, making
it much easier to squeeze extra lines in at any point int he program.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

Sep 7 '06 #14

P: n/a
At Thursday 7/9/2006 13:44, Omar wrote:
>I'm working through a tutorial,
http://swaroopch.info/text/Byte_of_Python:Control_Flow, and I sorta
can't get through the tutorial without overcoming these little
speedbumps. This is why I'm asking these questions.
Have you read the Python tutorial which comes with the documentation?
You can read it online at <http://docs.python.org/tut/tut.html>

Gabriel Genellina
Softlab SRL


__________________________________________________
Preguntá. Respondé. Descubrí.
Todo lo que querías saber, y lo que ni imaginabas,
está en Yahoo! Respuestas (Beta).
¡Probalo ya!
http://www.yahoo.com.ar/respuestas

Sep 12 '06 #15

This discussion thread is closed

Replies have been disabled for this discussion.