Sunday, January 22, 2012

IDLE Windows and Saves

Let's have a look at 'idle', the GUI-fied command line for python...

Idle, the Python GUI

OK, looks pretty standard. It's got "Save" in the menu. Let's give it a try...

Let's see what got saved:
mag@rincewind:~/programming/python$ cat python-shell.txt
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "copyright", "credits" or "license()" for more information.

Personal firewall software may warn about the connection IDLE
makes to its subprocess using this computer's internal loopback
interface. This connection is not visible on any external
interface and no data is sent to or received from the Internet.

IDLE 2.6.4
>>> print 'I\'m a lumberjack and I\'m OK!"
SyntaxError: EOL while scanning string literal
>>> print 'I\'m a lumberjack and I\'m OK!'
I'm a lumberjack and I'm OK!

Yuck. Everything got saved. How do we save a program? Lessee...

Aha, a "New Window" item on the menu. Maybe that'll give me an uncluttered window. But what about the prompt? Ah, let's just click it and find out.

Ah, a clear window appears. Let's type something in and save it as ''.

A simple python program entered in a New Window in IDLE.

Let's have a look at the file:
mag@rincewind:~/programming/python$ cat
print "I'm a lumberjack and I'm OK!"

That's more like it. Let's try running it from the command line...
mag@rincewind:~/programming/python$ python
I'm a lumberjack and I'm OK!

OK, so idle works as an editor. Now, how about running it in idle? Hmmm...'Open' in the interactive window?

Nope. That just opens the other window.

I can copy and paste, and that works, but it's not very clean. Gotta be a better way.

D'oh! There's a menu item right there that says "Run". Let's see..."Python Shell"?

Nope, that just takes me back to the other window. How about "Run Module F5"?
>>> ================================ RESTART ================================
I'm a lumberjack and I'm OK!

Aha! That's the ticket.

Time for a soda.

No comments:

Post a Comment