[Tutor] IDLE question

credo credo2004 at fmail.co.uk
Sat Jan 10 04:47:25 EST 2004

On Fri, 09 Jan 2004 22:37:06 -0300, "Gustavo Campanelli"
<birdiepage at ciudad.com.ar> said:
> antonio salgado wrote:
> >Hi there to all. I;m new to programming and new to Python, a friend of mine recommended me to start to learn whit this.
> >I want to know if when writting an instruction and get an error message the IDLE gets you to "another sentence" starting with the ">>>" you have to write everything all over again or if you can keep going whit the things you were doing?
> >I was copying the "Animals" script to start.
> >thanks for your time and understanding. I can't get any info on that, so I ask you all.
> >thank you again
> >P.S. any tips on self learning?
> >
> this goes a little 
> different for Linux people, who need a first line in that file to tell 
> Bash what to use to execute the code, as with any Linux script

For linux people just add:

#! /usr/bin/env python

to the top of your python script (myprogram.py) and remember to chmod to
make the script executable
(chmod 744 myprogram.py)

then simply type the command at the shell and it'll run. 

Alternatively you could simply run the script without all that by typing
this at the shell: 
python myprogram.py

If youre gonna use IDLE. Its easier to goto File -> New. Type your
program out on that page, and save. Then to run simply goto Run -> Run
Module. This should cause the interpreter to jump up and run your prog :)

The interpreter is a great tool for trying out code fragments to see if
they function, once they do, then you can add them to your actual script.
For a while i didn't really understand the concept, (still a newbie
myself), but am learning to appreciate it now ;) Its not much use for
writing an entire program in though :D

If you do hit an error in the idle interpreter, in my experience, it
seems to hold any constants/variable values that you have created just
fine, so you may only need to redo the last bit of code. For example:

>>> a = 1
>>> b = 2
>>> c = 3
>>> print d

Traceback (most recent call last):
  File "<pyshell#6>", line 1, in -toplevel-
    print d
NameError: name 'd' is not defined
>>> print a,b,c
1 2 3

As you can see, the values i defined for a,b,c were held despite the
error and i was able to continue just fine. :)

Hope some of the above helps and congrats on becoming a pythoneer :)


http://www.fastmail.fm - mmm... Fastmail...

More information about the Tutor mailing list