Python is a language of shortcuts. Things that take multiple lines of code in other languages take fewer lines in Python. String manipulation is a particularly strong suit for Python. When defining a string both single and double quotes work. To escape special characters such as carriage return you must use the backslash (\) character followed by the decimal equivalent. The concept of slices makes it easy to grab a part of a string as in:
>>> Str = 'This is a string'
When you need to build a really long string that spans several lines of text you can use the triple quote construct to surround the entire line as in:
VeryLongString = '''
Now is the time for all good men to come
To the aid of their countrymen. '''
Strings can span multiple lines of text as long as they are enclosed in triple quotes.'''
While Python is a dynamic language it is still strongly typed in a sensemeaning every object has a type. Python includes a number of built-in types such as lists, tuples, and dictionaries for simplifying many traditional programming tasks. On the other hand you don't declare variables with a type as you do in other languages such as C# or Java. The Python interpreter takes care of that for you sometimes to a fault. If you use the same name for a variable in two different parts of a program the first gets overwritten by the secondan obvious potential for hard-to-find bugs.
As a scripting language Python does the job of letting you build quick little programs in a short amount of time and test them interactively to make sure they work correctly. The Python library includes a multitude of pre-defined functions that make the job of coding much easier. You can also find numerous sample examples code on the Web, including code for such tasks as automating Word and Excel, interacting with Active Directory, and accessing the Windows Management Interface (WMI).
|Figure 1. IronPython Console: The IronPython Console app provides an interactive interpreter where you can try out parts of the language.|
The first public mention of IronPython was at the PyCON conference held in March of 2004 in Washington, DC. In this paper
, Jim Hugunin describes the work he did to implement the full semantics of the Python language on top of the Common Language Runtimeeither Microsoft's .NET version or the Mono platform. The paper goes on to describe his research and the test results.
Early implementations of IronPython worked on version 1.1 of the .NET runtime. Later releases target the upcoming version (2.0). As of this writing the latest IronPython version is 0.7.5 and requires the .NET Framework Version 2.0 Redistributable Package Beta 2
The interactive console includes a built-in command (dir
) that lists all the functions within a module. Figure 1
shows a list of all the functions included in the sys
module. Python's help
function has not been implemented in this version of IronPython.