Skip to main content

Python IDLE

IDLE is usually referred to as an integrated development environment (IDE), because it binds together various development tasks into a single view. The Raspberry Pi Operating Systems like Raspbian, OpenElec etc. comes with preinstalled Python IDLE. If you are interested to download Python IDLE for your PC or Laptop click here. To know more about installing Python IDLE click here. In this link the author is saying about how to install Python 3.4.3 which is now I am using.

The IDLE User Interface

If you’re looking for something a bit more visual, IDLE provides a graphical user interface for doing Python development, and it’s a standard and free part of the Python system. You can also run Python code with the interactive prompt, system command lines, Unix-style scripts, icon clicks, module imports, and exec calls. Since these not important for a Raspberry-Pi programming. However this will be discussed in this blog later. As mentioned above IDLE binds together various development tasks into a single view. In short, IDLE is a desktop GUI that lets you edit, run, browse, and debug Python programs, all from a single interface. It runs portably on most Python platforms, including Microsoft Windows, X Windows (for Linux, Unix, and Unix-like platforms), and the Mac OS (both Classic and OS X). For many, IDLE represents an easy-to-use alternative to typing command lines, a less problem-prone alternative to clicking on icons, and a great way for newcomers to get started editing and running code. You’ll sacrifice some control in the bargain, but this typically becomes important later in your Python career.

IDLE Startup Details

Most readers should be able to use IDLE immediately, as it is a standard component on Mac OS X and most Linux installations today, and is installed automatically with standard Python on Windows. Because platforms specifics vary, though, I need to give a few pointers before we open the GUI. Technically, IDLE is a Python program that uses the standard library’s tkinter GUI
toolkit (named Tkinter in Python 2.X) to build its windows. This makes IDLE portable —it works the same on all major desktop platforms—but it also means that you’ll need to have tkinter support in your Python to use IDLE. This support is standard on Windows, Macs, and Linux, but it comes with a few caveats on some systems, and startup can vary per platform. Here are a few platform-specific tips:
• On Windows 7 and earlier, IDLE is easy to start—it’s always present after a Python install, and has an entry in the Start button menu for Python in Windows 7 and earlier. You can also select it by right-clicking on a Python program icon, and launch it by clicking on the icon for the files
idle.pyw or idle.py located in the idlelib subdirectory of Python’s Lib directory. In this mode, IDLE is a clickable Python script that lives in C:\Python33\Lib\idlelib, C:\Python27\Lib\idlelib, or similar, which you can drag out to a shortcut for one- click access if desired.
• On Windows 8, look for IDLE in your Start tiles, by a search for “idle,” by browsing your “All apps” Start screen display, or by using File Explorer to find the idle.py
file mentioned earlier. You may want a shortcut here, as you have no Start button menu in desktop mode.
• On Mac OS X everything required for IDLE is present as standard components in your operating system. IDLE should be available to launch in Applications under
the MacPython (or Python N.M) program folder. One note here: some OS X versions may require installing updated tkinter support due to subtle version dependencies I’ll spare readers from here; see python.org’s Download page for details.
• On Linux IDLE is also usually present as a standard component today. It might take the form of an idle executable or script in your path; type this in a shell to check. On some machines, it may require an install line or icon click: run the file idle.py located in the idlelib subdirectory of
Python’s /usr/lib directory (run a find for the exact location).

IDLE Usability Features

Like most GUIs, the best way to learn IDLE may be to test-drive it for yourself, but some key usage points seem to be less than obvious. For example, if you want to repeat
prior commands in IDLE’s main interactive window, you can use the Alt-P key combination to scroll backward through the command history, and Alt-N to scroll forward
(on some Macs, try Ctrl-P and Ctrl-N instead). Your prior commands will be recalled and displayed, and may be edited and rerun.

You can also recall commands by positioning the cursor on them and clicking and pressing Enter to insert their text at the input prompt, or using standard cut-and-paste
operations, though these techniques tend to involve more steps (and can sometimes be triggered accidentally). Outside IDLE, you may be able to recall commands in an interactive session with the arrow keys on Windows.
The main Python shell window of IDLE GUI, shown here running on windows
Besides command history and syntax colorization, IDLE has additional usability features such as:
• Auto-indent and unindent for Python code in the editor (Backspace goes back one level)
• Word auto-completion while typing, invoked by a Tab press
• Balloon help pop ups for a function call when you type its opening “(”
• Pop-up selection lists of object attributes when you type a “.” after an object’s name and either pause or press Tab Some of these may not work on every platform, and some can be configured or disabled if you find that their defaults get in the way of your personal coding style.

Advanced IDLE Tools

Besides the basic edit and run functions and the prior section’s usability tools, IDLE provides more advanced features, including a point-and-click program graphical debugger and an object browser. The IDLE debugger is enabled via the Debug menu and the object browser via the File menu. The browser allows you to navigate through the
module search path to files and objects in files; clicking on a file or object opens the corresponding source in a text edit window.

You initiate IDLE debugging by selecting the Debug→Debugger menu option in the main window and then starting your script by selecting the Run→Run Module option in the text edit window; once the debugger is enabled, you can set breakpoints in your code that stop its execution by right-clicking on lines in the text edit windows, show variable values, and so on. You can also watch program execution when debugging— the current line of code is noted as you step through your code. 

For simpler debugging operations, you can also right-click with your mouse on the text of an error message to quickly jump to the line of code where the error occurred—a
trick that makes it simple and fast to repair and run again. In addition, IDLE’s text editor offers a large collection of programmer-friendly tools, including advanced text and file search operations we won’t cover here. Because IDLE uses intuitive GUI interactions, you should experiment with the system live to get a feel for its other tools.

More about Python IDLE

IDLE is free, easy to use, portable, and automatically available on most platforms. I generally recommend it to Python newcomers because it simplifies some startup details and does not assume prior experience with system command lines. However, it is somewhat limited compared to more advanced commercial IDEs, and may seem heavier than a command line to some. To help you avoid some common pitfalls, here is a list of issues that IDLE beginners should bear in mind:
You must add “.py” explicitly when saving your files. I mentioned this when talking about files in general, but it’s a common IDLE stumbling block, especially for Windows users. IDLE does not automatically add a .py extension to filenames when files are saved. Be careful to type the .py extension yourself when saving a file for the first time. If you don’t, while you will be able to run your file from IDLE
(and system command lines), you will not be able to import it either interactively or from other modules.
Run scripts by selecting Run→Run Module in text edit windows, not by interactive imports and reloads. Earlier in this chapter, we saw that it’s possible to run a file by importing it interactively. However, this scheme can grow complex because it requires you to manually reload files after changes. By contrast, using the Run→Run Module menu option in IDLE always runs the most current version of your file, just like running it using a system shell command line. IDLE also prompts you to save your file first, if needed (another common mistake outside IDLE).
You need to reload only modules being tested interactively. Like system shell command lines, IDLE’s Run→Run Module menu option always runs the current version of both the top-level file and any modules it imports. Because of this,
Run→Run Module eliminates common confusions surrounding imports. You need to reload only modules that you are importing and testing interactively in IDLE. If
you choose to use the import and reload technique instead of Run→Run Module, remember that you can use the Alt-P/Alt-N key combinations to recall prior commands.
You can customize IDLE. To change the text fonts and colors in IDLE, select the Configure option in the Options menu of any IDLE window. You can also customize key combination actions, indentation settings, autocompletions, and more;
see IDLE’s Help pull-down menu for more hints.
There is currently no clear-screen option in IDLE. This seems to be a frequent request (perhaps because it’s an option available in similar IDEs), and it might be added eventually. Today, though, there is no way to clear the interactive window’s
text. If you want the window’s text to go away, you can either press and hold the Enter key, or type a Python loop to print a series of blank lines (nobody really uses the latter technique, of course, but it sounds more high-tech than pressing the Enter key!).
tkinter GUI and threaded programs may not work well with IDLE. Because  IDLE is a Python/tkinter program, it can hang if you use it to run certain types of
advanced Python/tkinter programs. This has become less of an issue in more recent versions of IDLE that run user code in one process and the IDLE GUI itself in another, but some programs (especially those that use multithreading) might still hang the GUI. Even just calling the tkinter quit function in your code, the normal
way to exit a GUI program, may be enough to cause your program’s GUI to hang if run in IDLE (destroy may be better here only). Your code may not exhibit such problems, but as a rule of thumb, it’s always safe to use IDLE to edit GUI programs but launch them using other options, such as icon clicks or system command lines.
When in doubt, if your code fails in IDLE, try it outside the GUI.
If connection errors arise, try starting IDLE in single-process mode. This issue appears to have gone away in recent Pythons, but may still impact readers using older versions. Because IDLE requires communication between its separate
user and GUI processes, it can sometimes have trouble starting up on certain platforms (notably, it fails to start occasionally on some Windows machines, due to firewall software that blocks connections). If you run into such connection errors,
it’s always possible to start IDLE with a system command line that forces it to run in single-process mode without a user-code subprocess and therefore avoids communication issues: its -n command-line flag forces this mode. On Windows, for example, start a Command Prompt window and run the system command line
idle.py -n from within the directory C:\Python33\Lib\idlelib (cd there first ifneeded). A python -m idlelib.idle –n command works from anywhere.
Beware of some IDLE usability features. IDLE does much to make life easier for beginners, but some of its tricks won’t apply outside the IDLE GUI. For instance, IDLE runs your scripts in its own interactive namespace, so variables in your code show up automatically in the IDLE interactive session—you don’t always need to run import commands to access names at the top level of files you’ve already run. This can be handy, but it can also be confusing, because outside the IDLE environment names must always be imported from files explicitly to be used. When you run a file of code, IDLE also automatically changes to that file’s directory and adds it to the module import search path—a handy feature that allows you to use files and import modules there without search path settings, but also
something that won’t work the same when you run files outside IDLE. It’s OK to use such features, but don’t forget that they are IDLE behavior, not Python behavior.

Comments

Popular posts from this blog

8051 Simple Programs

Sum of 8-bit Numbers Stored in Memory Here  we will discuss about 8051 programs but we can't discuss about all of the 8051 instructions. For programming 8051 we should know about assembler directives as well as instruction set. Click  here to download Atmel c51 user guide that will discuss about 8051(c51 family microcontroller) instruction set, assembler directives, c51 cross assembler from Atmel.  Program ORG 00H MOV R0,#50H   ; get memory location in memory pointer R0 MOV R1,#51H   ; get memory location on memory pointer register R1 MOV A,@R0       ; get content of memory location 50H to accumulator ADD A,@R1        ; add content of A with content of memory location 51H and store result in A MOV R0,#52H    ; get 52H to memory pointer R0 MOV@R0,A         ; copy content of A to memory location 52H END Add 16-bit Numbers Program ORG 00H MOV DPTR,#2040H   ; get 2040H into DPTR MOV A,#2BH              ; get lower byte of second 16-bit number on accumulator MO

Introduction to 8051 embedded C

For 8051 we need to include the file reg51.h. This file contains the all the definitions of 8051 registers. With this information C compiler produces hex file that can be downloaded into the ROM of the microcontroller. It is important to note that the size of the hex file produced by the assembly language is much larger than the hex file produced by C compiler. Apart from this fact, there is many reasons for writing programs in C instead of assembly: ●It is much easier and less time consuming to write programs in C assembly. ●C is more flexible; it is easier to modify and update. ●Programming in C allows to use code available in function libraries. ●Program written inC for one microcontroller is portable to other microcontrollers with little or no modifications. Data Types in 8051 Embedded C The table shown below lists the data types that are available in typical C51 compiler. The gives information about the size of the data variable and it's value range. Data type

Even and Odd Memory Banks

The 8086 microprocessor uses a 20-bit address to access memory. With 20-bit address the processor can generate 2 20 = 1 Mega address. The basic memory word size of the memories used in the 8086 system is 8-bit or 1-byte (i.e., in one memory location an 8-bit binary information can be stored). Hence, the physical memory space of the 8086 is 1Mb (1 Mega-byte). For the programmer, the 8086 memory address space is a sequence of one mega-byte in which one location stores an 8-bit binary code/data and two consecutive locations store 16-bit binary code/data. But physically (i.e., in the hardware), the 1Mb memory space is divided into two banks of 512kb (512kb + 512kb = 1Mb). The two memory banks are called Even (or Lower) bank and Odd (or Upper) bank. The organization of even and odd memory banks in the 8086-based system is shown in Figure. The 8086-based system will have two sets of memory IC's. One set for even bank and another set for odd bank. The data lines D 0 -D 7 are conne