IT DRILLDOWN
 
NEWSLETTERS
 

CIO.com updates, insights and advice on technology, management and your career.

 Advice and Opinion

 CIO Consumer IT

 CIO Leader

 CIO Enterprise

 CIO Insider

 

RSS Feeds »

 
 
LEADERSHIP
 

CIO Executive Programs

The Leader in Face-to-Face Education for Senior Executives

Offering regional and national programs, CIO (and CSO) events bring together some of the most respected names and thought leaders in information technology and security. Presented by CIOs and other senior level executives, these invitation-only programs offer timely topics and strong networking. Learn More »

 

CIO Executive Council

Public Teleconferences

Join CIO Executive Council members and participate in the following live teleconferences:

* Planning for Succession:
Models for IT Leadership Development, June 23
* Youth in IT: How CIOs Can Engage the Next Generation
June 10
* Change Leadership at General Growth Properties: A
Pathways Leadership Development Seminar, June 25

More / Register »

Learn more about the CIO Executive Council »



 
 
RESOURCE CENTER
 
 
 
SUBSCRIBE TO CIO
 

Are you involved in setting the direction for your company's IT budget or strategy?


Apply today for a FREE subscription to CIO Magazine!

Subscription Services »

Reprints »

 
 

Feature

 

You Used Python to Write WHAT?

Python is a powerful, easy-to-use scripting language suitable for use in the enterprise, although it is not right for absolutely every use. Python expert Martin Aspeli identifies when Python is the right choice, and when another language might be a better option.
 

February 19, 2008CIO — Programming language decisions often come down to personal preference and experience. Most modern languages are capable of performing the majority of programming tasks and include the necessary libraries to be useful day to day. Sometimes, interoperability concerns can dictate a particular platform, but nowadays, interoperability is commonly best achieved through XML interchange, shared SQL databases or Web services.

Therefore, when choosing a language for a particular purpose, it is often more important to look at how a language is designed, what it makes particularly easy, and what it makes more difficult. If features or performance do not detract, intangibles such as "feel," "elegance" and a sense of programmer productivity should be given serious weight.

Python is a powerful, opinionated and idiosyncratic scripting language, loved (and hated) by programmers the world over for its style, syntax and attention to whitespace. It excels as a "glue" language for putting together applications quickly, and many Python developers feel more productive in Python than in other languages. This article shows you why, and also points out situations when Python is perhaps not such a good choice.

First, let's take a quick look at the way Python works: a very short technical overview (suitable even for nontechnical managers).

To give you a feel for how Python looks, here is a short code snippet:

def say_hello(name):
      """ Issue a familiar greeting
      """
      print "Hello %s" % name
  
  say_hello("Guido")

You may not know much about Python, but you can probably guess what's going on. This is Python's single best feature: Things generally work the way you expect. This obviousness in syntax makes the language relatively easy to learn for new programmers and easy to remember for occasional ones. However, the fact that it differs substantially from most other languages can be a barrier.

Programming the Way Guido Indented It

Python was created by Guido van Rossum, its "Benevolent Dictator for Life." The language and its standard library are developed by a thriving open-source community, but under Guido's watchful eye, Python's consistency and spirit remain intact. First released in the 1990s, Python is still evolving today.

Python is fully object oriented and includes a few functional programming constructs. It also has built-in support for commonly used data structures such as lists, dictionaries and sets. Its creators emphasize readability, consistency and simplicity; they believe that programming languages should be concise, but not too clever for their own good.

The main implementation of Python is written in C and runs on virtually any modern platform. There are also implementations that run inside a Java Virtual Machine (Jython, JPype), on the .Net platform (IronPython) and even one written in Python itself, called PyPy.

The C implementation is highly optimized, and is usually more than fast enough for normal programming tasks. However, if raw speed is your primary priority, look to a compiled language such as C. For embedded systems with limited memory, Python's runtime overhead may also be a problem.

Python as a General-Purpose Language

Python is the default choice of scripting language for many developers. In the words of one Pythonista, it is rare to start a project with Python and discover that it was an entirely inappropriate choice as it grows, because Python scales both in project size and performance. That said, the degree of freedom that the language grants developers means they sometimes have to be a little more disciplined in how they structure their code.

It takes almost no effort to get started with Python. At its simplest, you can just launch the python interpreter and type away in interactive mode. The results of your statements are printed to the console immediately:

$ python
>>> price = 30.0
>>> quantity = 2
>>> print "Total: %f" % round(price * quantity)
The total cost is 60.0

Of course, this is useful only for very simple tasks, but save those statements to a file with a .py file, run that file through the interpreter and the script is executed.

As programs grow more complex, developers may define functions and classes and split code across multiple modules, or source files that make up the same program. Modules can be organized into packages, which can be turned into distributable, self-contained bundles (known as eggs).

You can find thousands of free Python packages at the Python Package Index. For day-to-day tasks, Python's standard library includes everything from shell interaction to file management, XML and CSV manipulation, and much more.

Python has a strong role in business computing, particularly in Web and enterprise development. Let's take a look at when it's the best (and not-so-best) choice.

 
 
 
 
 
 
Loading...
 
 
ABCs
 

How To Do Nearly Anything

Just the basics, please. Sometimes we all need a refresher or we need to make sure our team and our colleagues are all on the same page.

Over 25 tutorials on everything from business intelligence to virtualization.

 
 
FEATURED SPONSORS
 
 
 
SPONSORED LINKS
 

Enterprise Service Bus: A Definition

Model, Execute, and Optimize: Oracle Fusion Middleware and the BPM Lifecycle

Case Study: Customer Integration Wins at Invitrogen

Internet's Largest Book Retailer Scores Big with B2B Customers

Establishing a Strategy for Global Distributed Development

Drive More Effective Business Processes with SOA

Fuel the Responsive Enterprise Through Oracle Fusion Middleware

Oracle 9i Database Upgrade Management Services - Upgrade with Confidence

Extending the Enterprise Network Through Mobility

Global Crossing is the most viable alternative for voice, video and data.

The New Foundation of Storage: Xiotech's Intelligent Storage Element

BPM Done Right: 15 Ways to Succeed Where Others have Failed

3 Reasons to Invest in Integration Technology Now

A CIO's View of Server Virtualization

Let's Get Virtual: A Look at Today's Server Virtualization Architectures

Increase conversions on your site with the help of EV SSL.

Get Control of Mobile Data (and More)

Data Loss Prevention Starts at the Endpoint

Building a Foundation for Pragmatic Service Management White Paper

Performance Brief: Mobile Application Acceleration

Strategies for centralizing data backup

Citrix XenServer FREE trial

Nothing Short of Revolutionary: Four Steps toward More Effective Enterprise Finance

The Best IT Strategy for a Company with Global Operations

Speed, agility, flexibility - The HP BladeSystem c-Class

White Paper: Assess Your SOA

People, Processes, and SOA: Oracle Fusion Middleware and the Responsive Enterprise

Learn about B2B integration for Companies of All Sizes

Integration as a Service Webcast: Are you connected?

BEA & Forrester Webcast: "The Enterprise 2.0 Workplace." Register Now!

Balance Your Innovation and Efficiency Platforms for Competitive Advantage and Responsiveness

Oracle & SUN Team to Rise Above the Upgrade Challenge

Learn how to communicate the business value of IT

White Paper: Learn how to succeed with BPM

Webcast: Research insight into how organizations are using virtualization

ITIL V3 and the IT Service Catalog

The New Growth Paragidm: Multi-Enterprise SOA

3M saved $3M on printing. Learn how HP can help your business

Survival of the Fittest: Disaster Recovery Design for the Data Center

Windows Server 2008: To Upgrade or Not to Upgrade?

How Office 2007 Exposed Bill Gates

How to simplify mobility and reduce the cost of supporting mobile workers

Helping IT Become a Service Provider White Paper

Extending PCI Compliance to the Mobile Workforce

A proven approach to WAN optimization

Wireless Vulnerability Management: What It Means for Your Enterprise

Green IT: Reducing Your Carbon Footprint with Citrix

Wide-area data services enable todays global enterprise

Discover PMI's credentials and career path tools

Symantec State of the Data Center Report