Python IDE - One Day of iDLE Toying

xiaoxiao2021-03-06  41

One day of idle pointing

Spanish translation by Jose Miralles-Santana Thai translation by Pramote Khuwijitjaru Malaysian translation by Mohd. Fahmi Basar Korean translation by Jisoo Yi Chinese translation by Tongli Zhang Greek translation by Leon IV Isauvros Italian translation by Roberto Distefano Indonesian translation by I Wayan Wandira French translation by Yannick Gobin Dutch Translation by Mark Lambrecht German Translation by Gregor Lingl Portuguese Translation by Fernando Mana 鏰 S Ferreira

This page is meant to help new users of python who might feel a little disrtonded. One Question That Might Come To Mind IS: OK, We've Installed Python ... ummm ... now?

It might be nice to have a "visual" guide to reduce any initial anxieties That's what this page is for The plan is to go through a small session with IDLE:.. The Integrated Development Environment IDLE is designed to provide a simple way of. Exploring The Language. During this session, I'll make a fEW fulbling missakes, just to show what to excecting the things don't go exactly hunky-dory.

By the way, this is an online document If you have any suggestions, or if you want to make corrections or improvements, please feel free to email at dyoo@hkn.eecs.berkeley.edu Small plug:. Also, do not forget that there's a great resource in the Python Tutor mailing list: we're a group of people who like to show each other interesting stuff in Python We're all learning together, so feel free to subscribe and join us..

Changes

October 26, 2004: Jose Miralles-Santana sent me a Spanish translation Gracias February 10, 2004:.! Pramote Khuwijitjaru sent me a translation in Thai Kob-Kkun February 2, 2004:.! A reader named Jim noticed that the link to the Beginner's Tutorials Doesn't Go To The Right Place Anymore! Fixed The link to http://www.python.org/topics/learn/non-prog.html January 7, 2004: Mohd. Fahmi Basar Has Written A Wonderful Translation Into MA-SiH! And Maafkan Saya As Well; I'm So Sorry for Being So Late About Updating The page. One Drove Out Another, As One Might Say. June 4, 2003: I Forgot To Put this link Up: One Day of MacPython IDE Toying is an adaptation of this tutorial for MacPython Much nicer screenshots, too * grin * March 11, 2003:..!! Jisoo Yi just sent me a translation into Korean Gam sa hap nee da February 8, 2003: Tongli Zhang Sent Me A New Translation of The Idle Tutorial in Chinese. Shie-shie! January 9, 2003: Leon IV Isauvros Has Written a Greek Translation! Sas Efhar isto poli December 13, 2002:! Roberto Distefano wrote a translation in Italian This is awesome Grazie August 26, 2002:.!!.! I Wayan Wandira has translated the tutorial into Indonesian Selamat tinggal Also, I've implemented Ferg_S's suggestion to add page-breaking BR tags to make a dead-wood version of the guide more pleasant to read July 8, 2002:. Yannick Gobin graciously donated a French translation Merci April 30, 2002:.! Mark Lambrecht donated his Dutch translation Dankzegging January.! 30, 2002: Fernando Mana 鏰 S Ferreira Sent Me A Portuguese Translation. This is Wonderful! Obrigado! December 4 (evening): Gregor Lingl Sent Me A German Translation of the Guide. Danke! December 4, 2001: There '

S, So I'VE Tried to Patch The Fixme's Throughout this page........................................................................................................................................................................................................................................................................... little delayed until I get it replaced My apologies] Ok, let's assume that we've already installed Python (If not, we can visit:.!. http://python.org and download the most recent Python interpreter As of this. Writing, That's Python 2.1.) The first thing we'd like to do is actually start running it! we can do this by opening up idle, Which shouth be in Our Start Menu Under The Newly-create Python Program Group.

We'll See That A New Window Magnificant Or Opens Up:

This is the main window to IDLE, and what we see right now is called the "Interpreter" window. The Interpreter allows us to enter commands directly into Python, and as soon as we enter in a command, Python will execute it and spit out . its result back to us We'll be using this Interpreter window a lot when we're exploring Python:. it's very nice because we get back our results immediately If it helps, we can think of it as a very powerful calculator.

Let's Try Something Now! As Per Tradition, Let's Get Python to Say The Immortal Words, "Hello World".

Those '>>>' Signs Act As a Prompt for US: Python Is Ready To Read in A New Command by Giving US That Visual Cue. Also, We Notice That As We Enter In Commands, Python Will Give US ITS Output Immediately.

OK, this Seems Pretty Simple Enough. Let's Try A Few More Commands. If We Look Below:

. We'll see the result of running a few more commands Do not worry too much about knowing the exact rules for making programs yet: the idea is that we can experiment with Python by typing in commands If things do not work,. then we can correct the mistake, and try it again.If you got to this point, you now know enough to start playing around with Python! Crack open one of the tutorials from the Python For Beginners web page, and start exploring with the interpreter No time limit here. * Grin *

Now That We've Padd LONG ENOUGH, WE Might Be asking: OK, this Is Neat, But Id The Computer To Remember What WE TYPER?

The solution is a little subtle: we can not directly save what's on the interpreter window, because it will include both our commands and the system's responses What we'd like is to make a prepared file, with just our own commands, and. To Be Able To Save That File As a Document. WE'RE In The Mood, We can Later Open That File and "Run" python over it, saving us the time of return the whole thing over again.

Let's try this. First, let's start with a clean slter by open a new window.

Here's The Result of That Menu Command:

We notice that there's nothing in this new window What this means is that this file is purely for our commands:. Python will not interject with its own responses as we enter the program, that is, not until we tell it to I '. Ll Call this The "Program" Window, To Distinguish It from the interpreter window.

What we wanted to do before was save some of the stuff we had tried out on the interpreter window. Let's do that by typing (or copy / pasting) those commands into our Program window.Ok, we're done with copying and pasting. One big thing to notice is that we're careful to get rid of the ">>>" prompts because there's not really part of our program. The interpreter uses them just to tell us that we're in the interpreter, but now that We're Editing in a Separate File, We can remove the artifacts That The Interpreter Introducture.

Let's save the file now. The save command is located under the file menu:

Now That We've Saved The Program, How do we run the program? If we look at the menus on Our Program Window,

We'll See That There's a menu Option to "Run Script", and That's What Weame Python Running Through To See IS Python Running THROUGH THE PROGRAM, AND DISPLAYING ITS RESULTS IN The Interpreter Window.

By The Way, One Thing to NOTICE IS That I Made A Typo: i Didn't Quite Copy Exactly What i Had Entered In The Interpreter WINDOW BEFORE. Does this affect thing

Ooops. Here is an example of what Python calls a "syntax error". Python sees that we made a typo, and warns us to take a much closer look at our program. The designers of Python feel that having the system point out the error is better than trying to guess at what the programmer meant. It's the idea of ​​explicitness versus implicitness. There are certain rules that Python follows that measure what looks good and what looks suspicious. As we speak the language, we'll get a feel for Suspicious, You, this is a bit like grammar. * Grin *

Python is often perceptive enough to direct us toward the problem, and in this case, it's telling us that we forgot to put something at the end of this line. In this case, we need to add an additional quotation mark. Let's add that in Now.ok, Let's Say That We Fixed That Silly Typo. Let's Try To Run The Program.

Another snag, but not that complicated, just silly One other thing that might put us off guard is that IDLE wants us to save any Program windows before we run them;. This is a user interface issue that makes sure that we save our work before We Start Running The Program.

(Note: the comment above might be outdated; enough people got annoyed by IDLE's lazy behavior that they've clamored for change We hope that the development version of IDLE does not give this error message anymore..)

................. ..

As we play with Python, we'll find ourselves "switching modes" between the Interpreter window and the Program window. The reason for this is because we can use the Interpreter as if it were a small laboratory and experimentally try small programs. After we 'Re Satisfied (or When We're Tired), WE CAN Save What Weame Learned Into a Program File.

This, Of Course, Assumes That We can Actually Load The File Later ON; It Would Be A Silly Thing to Save a Program, And Not Be Aable To Load It Up Later. Let's Show this, and the stop for today. I'll Close Everything Down IN IDLE, AND Start from a Clean Slate.

We'll Find The Open Command Under The File Menu:

Andiff All Goes Well, We Should See A New Program Window Open Up:

With our old program! We can save our old work and open it up at a later time. it's not jaw-opening, but it is crucial for the Person Wants to Play with Python for more Than Day . * grin * This is pretty much all we need to know about IDLE to actually do interesting things This guide has skipped a lot of stuff about IDLE:. IDLE is much more than an mere editor, but it takes some time to explore all of its features, so let's stop for now there's a IDLE Documentation page that explains advanced IDLE use, for those with an insatiable curiosity Again, if you have any questions, please feel free to stop by the Python Tutor mailing list;.. there's usually someone There Who'd Be Happy To Chat About Python with you. It's been fun, and i hood this has been helpful!

Back to my personal python page.

转载请注明原文地址:https://www.9cbs.com/read-50923.html

New Post(0)