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.

By Martin Aspeli
Tue, February 19, 2008

CIO — 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.

Continue Reading

With 1.5 billion instructions in one second (BIPS), while consuming less energy than ever before, Wintergreen Research says IT departments need to sit up and take notice of this hybrid system that combines the System z with servers.
Learn how your answer to this question compares to your peers by taking this quick poll. See how your peers are dealing with the challenge of ensuring a highly capable server infrastructure as technological shifts impact the application server platform.
With increasing data growth, comes increased need for data security.  The existing DLP model, with a focus on compliance/enforcement is not sufficient as the data discovery and classification capabilities are not granular enough.  Read this paper to find how you can efficiently and accurately manage your risk by rapidly inventorying and classifying your data and then developing remediation workflows that support business needs. 
This paper breaks down attack sources into four categories: external, malicious insiders, accidental insiders, and unknown.
The rapid growth of data and technology is creating challenges for organizations as this digital data is considered to be business communications and must be preserved according the same industry-specific regulations governing the retention and discovery of emails and more traditional forms of electronic communications. This paper examines the role that Data Loss Prevention ("DLP") technology can play in helping organizations address the challenges of locating information in response to electronic discovery.
This research, conducted by the Ponemon Institute, focuses on issues relating to the use of data protection solutions such as endpoint encryption and data loss prevention within the workplace.
As greater numbers of datacenter servers transition from the physical to the virtual world, the components of virtualization success come to the fore. What scores of organizations have discovered is that success is derived from an optimal pairing of the right software platform with the right hardware platform.
Have you been looking to hear about customer's experiences with the new VMware vCenter Site Recovery Manager product? View this webcast to learn about VMware customer, Navicure, and their experiences testing and evaluating the recovery manager, their progress in implementing it in their environment and their advice other customers considering using vCenter.
Many enterprises have discovered that the use of virtualization to support desktop workloads creates a range of significant benefits. These benefits include price efficiencies, improved IT management and greater agility and choice for end users.

This VMware sponsored webcast with IDC will provide both quantitative measurement of the business value -- defined as the expected ROI -- and qualitative analysis associated with the use of VMware View™. IDC will also provide an analysis of the View Composer and ThinApp™ features of VMware View, including the business value of these solutions and an overview of how they work.

Attend this webcast to learn about:
- Challenges and barriers that might impede the adoption of desktop virtualization
- Navigating roadblocks to facilitate a strategic implementation
- Optimizing qualitative and quantitative benefits to IT and your business
VMware recently announced VMware vFabric™ Data Director, a new database deployment and operations platform that enables enterprise IT organizations to offer database as a private cloud service. Built on top of VMware vSphere 5, vFabric Data Director enables IT organizations to ontrol database sprawl through automation and consistent policy enforcement and accelerate application development cycles with self-service database management. Attend this webcast to learn how vFabric Data Director can help you build database-as-a-service in your datacenter.
A simple, cost-effective disaster-recovery solution for virtual environments is high on the agenda for IT organizations as they virtualize more business-critical applications with VMware. VMware vCenter™ Site Recovery Manager-the market-leading disaster-recovery product-ensures the simplest and most reliable disaster protection for all virtualized applications. VMware vCenter Site Recovery Manager provides centralized management of recovery plans, enables nondisruptive testing and automates site-failover processes.
Traditional disaster recovery solutions are often too expensive, complex and unreliable to meet business requirements. As a result, IT departments are hesitant to expand disaster protection beyond their most critical applications, largely because they are uncertain whether the quality of the protection is really worth its cost. VMware vCenter™ Site Recovery Manager 5 is the market-leading disaster recovery product that addresses this situation for organizations of all kinds. It complements VMware vSphere to ensure the simplest and most reliable disaster protection for all virtualized applications.
Newsletter Sign-Up »

Receive the latest news test, reviews and trends on your favorite technology topics

Choose a newsletter
  1. View all Newsletters | Privacy Policy
Resource Center