 |
 |
 |
 |
 |
 |
Charming Python: Distributing computing with RPyC
RPyC is a seamless library for integrating $@!LessThan!@$!--000 and interacting--$@!GreaterThan!@$ Python
processes on many machines/processes. This article looks at the advantages or
drawbacks RPyC has over other distributed Python frameworks such as XML-RPC
and Pyro. A few simple examples of using RPyC are included to give you a
feel for the library.
|
 |
Articles |
 |
31 Mar 2009 |
|
| |
Charming Python: Python elegance and warts, Part 2
In this series of two articles, David discusses the non-obvious features and
misfeatures that have been added to the last several Python versions, with the goal
of helping part-time Python programmers uncover the gems while avoiding the
pitfalls. This installment adds attributes and methods, descriptors, and properties
to the discussion.
|
 |
Articles |
 |
29 Aug 2007 |
|
| |
Charming Python: Python elegance and warts, Part 1
Since the "golden age" of Python 1.5.2 -- for a long time a stable and solid
version -- Python has greatly increased its number of syntactic features and
built-in functions and types. Each of these additions has reasonable justification,
in isolation, but taken as a whole, they make Python no longer a language that
experienced programmers can pick up "in an afternoon." Moreover, some of the changes
have pitfalls along with benefits.
|
 |
Articles |
 |
28 Mar 2007 |
|
| |
Charming Python: Decorators make magic easy
Python made metaprogramming possible, but each Python version has added
slightly different -- and not quite compatible -- wrinkles to the way you accomplish
metaprogramming tricks. Playing with first-class function objects has long been
around, as have techniques for peaking and poking at magic attributes. With version
2.2, Python grew a custom metaclass mechanism that went a long way, but at the cost
of melting users' brains. More recently, with version 2.4, Python has grown
"decorators," which are the newest -- and by far the most user-friendly way, so far
-- to perform most metaprogramming.
|
 |
Articles |
 |
29 Dec 2006 |
|
| |
Charming Python: Hatch Python eggs with setuptools
David takes a look at the setuptools framework, a side project of the Python Enterprise Application Kit (PEAK). setuptools replaces the standard distutils library and adds versioned package and dependency management to Python. Perl users will be familiar with CPAN, and Ruby users with Gems; the tool ez_setup that bootstraps setuptools and the expanded easy_install that comes with it act in conjunction with "Cheeseshop" (the Python Package Index, also called "PyPI") to achieve the same thing. Moreover, setuptools lets you package your libraries in a single-file archive called an "egg," which is a lot like a Java JAR file, but for Python.
|
 |
Articles |
 |
24 Oct 2006 |
|
| |
Charming Python: Scaling a new PEAK
The Python Enterprise Application Kit (PEAK) is a Python framework for rapidly developing and reusing application components. While Python itself is already a very high-level language, PEAK provides even higher abstractions. One fairly recent capability added to PEAK is the capability to create generic functions and specifically to dispatch them on predicates, not simply on type. Sounds mysterious? Let's investigate.
|
 |
Articles |
 |
15 Sep 2005 |
|
| |
Charming Python: Pyrex extends and speeds Python apps
The author takes a stab at speeding up his pure-Python version of hashcash using Pyrex, a language for writing Python extension modules that lets you avoid having to use C for the job. He contrasts writing code in Pyrex -- generally for use with larger Python applications -- with speeding up Python applications using the Psyco compiler, which he has written about previously on developerWorks.
|
 |
Articles |
 |
25 Jan 2005 |
|
| |
Charming Python: Beat spam using hashcash
Built on the widely available SHA-1 algorithm, hashcash is a clever system that requires a parameterizable amount of work on the part of a requester while staying "cheap" for an evaluator to check. In other words, the sender has to do real work to put something into your inbox. You can certainly use hashcash in preventing spam, but it has other applications as well, including keeping spam off of Wikis and speeding the work of distributed parallel applications. In this article, you'll meet David's own Python-based hashcash implementation.
|
 |
Articles |
 |
09 Nov 2004 |
|
| |
Charming Python: A look at DParser for Python
Get an introduction to DParser, a simple but powerful tool for parsing, written by J. Plevyak. Then learn about DParser for Python, which gives Python programmers a seamless interface to DParser, and see how it compares to other parsers covered in previous installments. In a manner similar to Spark or PLY, grammar rules are input to DParser using Python function documentation strings.
|
 |
Articles |
 |
28 Jul 2004 |
|
| |
Charming Python: Get started with the Natural Language Toolkit
In this installment, David introduces you to the Natural Language Toolkit, a Python library for applying academic linguistic techniques to collections of textual data. Programming that goes by the name "text processing" is a start; other capabilities for syntactic and even semantic analysis are further specialized to studying natural languages.
|
 |
Articles |
 |
24 Jun 2004 |
|
| |
Charming Python: The Python Enterprise Application Kit
PEAK is a Python framework for rapidly developing and reusing application components. While Python itself is already a very high-level language, PEAK provides even higher abstractions, largely through the clever use of metaclasses and other advanced Python techniques. In many ways, PEAK does for Python what J2EE does for the Java language. Part of the formalization in PEAK comes in the explicit specification of protocols, specifically in the separately available package, PyProtocols.
|
 |
Articles |
 |
04 May 2004 |
|
| |
Charming Python: Testing frameworks in Python
In this installment, David looks at Python's two standard modules for unit testing: unittest and doctest. These modules expand on the capability of the built-in assert statement, which is used for validation of pre-conditions and post-conditions within functions. David discusses the best ways to incorporate testing into Python development, weighing the advantages of different styles for different types of projects.
|
 |
Articles |
 |
08 Apr 2004 |
|
| |
Charming Python: Review of Python IDEs
David looks at four open source development environments for working with Python code on Unix-like operating systems. He evaluates two general-purpose editors/environments and two Python-specific ones, and compares the merits of each.
|
 |
Articles |
 |
11 Dec 2003 |
|
| |
Charming Python: Numerical Python
Numerical Python (often called NumPy) is a widely used extension library for fast operations on fixed-type arrays, of any dimensionality, in Python. Since the underlying code is well-optimized C, any speed limitations of Python's interpreter usually go away when major operations are performed in NumPy calls. As successful as NumPy has been, its developers have decided to supercede NumPy with a new module called Numarray that is mostly, but not quite entirely, compatible with NumPy. In this installment, David looks both at the general features of NumPy and at the specific improvements forthcoming with Numarray.
|
 |
Articles |
 |
30 Oct 2003 |
|
| |
Charming Python: Using combinatorial functions in the itertools module
Python 2.2 introduced simple generators to the Python language and reconceived standard loops in terms of underlying iterators. With Python 2.3, generators become standard (no need for _future_, and the new module itertools is introduced to work flexibly with iterators. The itertools module is essentially a set of combinatorial higher-order functions, but ones that work with lazy iterators rather than with finite lists. In this installment, David explores the new module, and gives you a sense of the new expressive power available with combinatorial iterators.
|
 |
Articles |
 |
12 Jun 2003 |
|
| |
Charming Python: Multiple dispatch
Object-oriented programming gains much of its versatility through polymorphism: objects of different kinds can behave in similar ways, given the right contexts. But most OOP programming is single dispatch; that is, just one designated object determines which code path is taken. Conceptually, a more general technique is to allow all the arguments to a function/method to determine its specialization. This article presents an implementation of multiple dispatch in Python, and shows examples where this makes for better programs."
|
 |
Articles |
 |
20 Mar 2003 |
|
| |
Charming Python: Create declarative mini-languages
The object orientation and transparent introspective capabilities of Python allow you to easily create declarative mini-languages for programming tasks. In this installment, David looks not so much at using Python to interpret or translate other specialized languages (although that is possible), but rather the ways that Python code itself can be helpfully restricted to a set of declarative elements. He'll show you how developers can use declarative techniques to state application requirements in a concise and clear way, while letting the behind-the-scenes framework do the heavy work.
|
 |
Articles |
 |
27 Feb 2003 |
|
| |
Charming Python: SimPy simplifies complex models
The stochastic behavior of real-world systems is often difficult to understand or predict. Sometimes it is possible rigorously to demonstrate statistical properties of systems, such as average, worst-case, and best-case performance features. But at other times, pitfalls of concrete designs only become evident when you actually run (or simulate) a system. In this article, David takes a look at SimPy, a Python package that allows you to very easily create models of discrete event systems.
|
 |
Articles |
 |
01 Dec 2002 |
|
| |
Charming Python: Make Python run as fast as C with Psyco
With only a tiny amount of extra programming, Python programmers can often increase code speed by orders of magnitude with the help of an external module known as the Python Specializing Compiler (or Psyco for short). David Mertz looks at what Psyco is, and tests it in some applications.
|
 |
Articles |
 |
01 Oct 2002 |
|
| |
Charming Python: Parsing with the Spark module
Spark is a powerful and general parser/compiler framework written in Python. In some respects, Spark offers more than SimpleParse or other Python parsers. Being pure Python, however, it is also slower. In this article, David discusses the Spark module, with code samples, an explanation of its usage, and suggestions for its areas of application.
|
 |
Articles |
 |
01 Aug 2002 |
|
| |
Charming Python: Generator-based state machines
Introduced in Python 2.2, simple generators may be used to simplify state machines and to simulate coroutines. Coroutines are an exotic flow mechanism that few widely used languages -- not even non-Stackless Python -- allow. Python's new generators, however, get you almost all the way to coroutines, and the extra few steps can be faked. In this installment of Charming Python, David Mertz explains all the relevant concepts through illustrative code samples.
|
 |
Articles |
 |
01 Jul 2002 |
|
| |
Charming Python: Implementing "weightless threads" with Python generators
David Mertz introduces weightless threads. Similar to Stackless Python microthreads, but using standard Python 2.2 -- they allow for extremely large numbers of cooperating processes with virtually no overhead.
|
 |
Articles |
 |
01 Jun 2002 |
|
| |
Charming Python: Updating your Python reading list, Part 3
Since David's last book roundup in November's Charming Python column, a number of interesting books on Python have been published. This installment provides new comparative reviews of recent Python titles (or titles missed in the last roundup).
|
 |
Articles |
 |
01 May 2002 |
|
| |
Charming Python: Parsing with the SimpleParse module
Many parsing tools have been written for Python. This column discusses a high-level parsing language built on top of Python.
|
 |
Articles |
 |
01 Jan 2002 |
|
| |
Charming Python: Updating your Python reading list, Part 2
This installment provides new comparative reviews of recent Python titles (or titles missed in the last roundup).
|
 |
Articles |
 |
01 Nov 2001 |
|
| |
Charming Python: Using the xinetd program for system administration
Every UNIX administrator is familiar with inetd, the daemon that manages most incoming network connections through a centralized configuration file (inetd.conf). The xinetd daemon is a replacement for inetd that offers many improved or new features, and easier configuration. Ted explains the concepts behind inetd, and gives examples for setting up xinetd at your own site.
|
 |
Articles |
 |
01 Nov 2001 |
|
| |
Charming Python: Preview of the [anygui] project
A very interesting project in the Python world has entered early development. The [anygui] project is intended as a wrapper API for a large number of underlying graphic toolkits. Once fully developed, a Python programmer will be able to call a common [anygui] function -- for example, to create a window -- then have the "best available" toolkit do the work. On Windows, the Win32 API might be used (or wxWindows); on MacOS, native calls; on BeOS, Bethon; on Linux, TKinter or GTK; on a telnet screen, ncurses -- all depending on what is installed and available on a given machine. This article discusses the current development state of [anygui], and the goals of the project.
|
 |
Articles |
 |
01 Oct 2001 |
|
| |
Charming Python: Iterators and simple generators
Python 2.2 introduces a new construct accompanied by a new keyword. The construct is generators; the keyword is yield. Generators make possible several new, powerful, and expressive programming idioms, but are also a little bit hard to get one's mind around at first glance. In this article, David provides a gentle introduction to generators, and also to the related topic of iterators.
|
 |
Articles |
 |
01 Sep 2001 |
|
| |
Charming Python: pydoc and distutils modules
The introduction of several modules and tools in recent Python versions has improved Python, not so much as a language, but as a tool. Author David Mertz reviews these modules that make the job of Python developers substantially easier by improving the documentation and distribution of Python modules and packages.
|
 |
Articles |
 |
01 Aug 2001 |
|
| |
Charming Python: Python for the PalmOS
Pippy is a port of (a subset of) Python to the PalmOS. With Pippy, Python programmers can create custom applications to run on Palm devices, as well as use Pippy as an interactive environment directly on the Palm. David evaluates the strengths and limitations of Pippy as a means of implementing Palm applications.
|
 |
Articles |
 |
01 Jul 2001 |
|
| |
Charming Python: Functional programming in Python, Part 3
David Mertz illustrates currying and other higher-order functions contained in the Xoltar Toolkit.
|
 |
Articles |
 |
01 Jun 2001 |
|
| |
Charming Python: Revisiting XML tools for Python
This special installment article revisits the author's previous discussion of XML tools, and provides up-to-date code samples.
|
 |
Articles |
 |
01 Jun 2001 |
|
| |
Charming Python: Developing a full-text indexer in Python
As the volume of information grows, effective means of locating specific information become ever more crucial. This column discusses the field of full-text indexing, with a focus on the author's public-domain indexer module.
|
 |
Articles |
 |
01 May 2001 |
|
| |
Charming Python: Functional programming in Python, Part 2
This column continues David's introduction to functional programming (FP) in Python. Enjoy this introduction to different paradigms of program problem-solving, where David demonstrates several intermediate and advanced FP concepts.
|
 |
Articles |
 |
01 Apr 2001 |
|
| |
Charming Python: Functional programming in Python, Part 1
Although users usually think of Python as a procedural and object-oriented language, it actually contains everything you need for a completely functional approach to programming. This article discusses general concepts of functional programming, and illustrates ways of implementing functional techniques in Python.
|
 |
Articles |
 |
01 Mar 2001 |
|
| |
Charming Python: Getting version 2.0
Python programmers have recently acquired a shiny new toy with the release of version 2.0. Python 2.0 builds on the strengths of previous Python versions, while adding a number of new conveniences and capabilities. This article contains ts author's impressions of Python's newest version, and some tips on using it effectively.
|
 |
Articles |
 |
01 Feb 2001 |
|
| |
Charming Python: Updating your Python reading list
In little more than a year, the availability of material for learning and programming in Python has gone from a thin selection of books to the current forest of dead trees. Some books are general introductions to the Python language, while others specialize in particular tasks. Even within the 'general' category, level and focus differ considerably. This column gives David's impressions and recommendations on eight of the best known books about Python.
|
 |
Articles |
 |
01 Feb 2001 |
|
| |
Charming Python: TK programming in Python
David Mertz introduces TK and the Tkinter wrapper (Python's GUI library) with source code samples accompanied by detailed running commentary. To make life easy, he illustrates his examples with the GUI port of the Txt2Html front-end that he's used in many of his earlier articles. He assumes, of course, that you follow his column regularly. :)
|
 |
Articles |
 |
01 Dec 2000 |
|
| |
Charming Python: TK programming in Python
David Mertz introduces TK and the Tkinter wrapper (Python's GUI library) with source code samples accompanied by detailed running commentary. To make life easy, he illustrates his examples with the GUI port of the Txt2Html front-end that he's used in many of his earlier articles. He assumes, of course, that you follow his column regularly. :)
|
 |
Articles |
 |
01 Dec 2000 |
|
| |
Charming Python: Inside JPython and Python for .NET
David Mertz interviews Mark Hammond, Finn Bock, and Barry Warsaw, the developers of JPython and Python for .NET. He gets a bit of the inside scoop on Microsoft development from Mark (all within the limits of his non-disclosure contract, of course), and grills Finn and Barry on JPython and their upcoming Jython project.
|
 |
Articles |
 |
01 Dec 2000 |
|
| |
Charming Python: Reloading on the fly
This article illustrates runtime program modification by means of some enhancements to the Txt2Html front-end.
|
 |
Articles |
 |
01 Nov 2000 |
|
| |
Charming Python: Inside Python's implementations
What most programmers probably think of when they talk about "Python" is the specific implementation sometimes called "CPython" (because it is implemented in C). However, Python as a language specification has been implemented several times in parallel with the evolution of Guido van Rossum's reference implementation. This article consists of annotated interviews with the creators of two of the non-standard Pythons -- Stackless and Vyper.
|
 |
Articles |
 |
01 Oct 2000 |
|
| |
Charming Python: Text processing in Python
Along with several other popular scripting languages, Python is an excellent tool for scanning and manipulating textual data. This article summarizes Python's text processing facilities for the programmer new to Python. The article explains some general concepts of regular expressions and offers advice on when to use (or not use) regular expressions while processing text.
|
 |
Articles |
 |
01 Sep 2000 |
|
| |
Charming Python: Curses programming
A certain class of Python applications works best with an interactive user interface without the overhead or complexity of a graphical environment. For interactive text-mode programs (under Linux/UNIX), for example, the ncurses library, wrapped in Python's standard curses module, is just what you need. In this article, David Mertz discusses the use of curses in Python. He illustrates the curses environment using sample source code from a front-end to the Txt2Html program.
|
 |
Articles |
 |
01 Sep 2000 |
|
| |
Charming Python: Using state machines
State machines, in a theoretical sense, underlie almost everything related to computers and programming. And it also turns out that state machines, in a practical sense, can help solve many ordinary problems (especially for Python programmers). In this article, David Mertz discusses some practical examples of when and how to code a state machine in Python.
|
 |
Articles |
 |
01 Aug 2000 |
|
| |
Charming Python: The dynamics of DOM
In this article, David Mertz examines in greater detail the use of the high-level xml.dom module for Python.
|
 |
Articles |
 |
01 Jul 2000 |
|
| |
Charming Python: My first Web-based filtering proxy
This article introduces Txt2Html, a public-domain working project created by David to illustrate programming techniques in Python. Txt2Html is a "Web-based filtering proxy" -- a program that reads Web-based documents for the user, then presents a modified page to the user's browser. To make this possible, Txt2Html runs as a CGI program, queries outside Web resources, and makes use of regular-expressions. David steps you through each of these general-purpose subtasks, explaining, clarifying, and demonstrating along the way.
|
 |
Articles |
 |
01 Jul 2000 |
|
| |
Charming Python: Tinkering with XML and Python
A major element of getting started on working with XML in Python is sorting out the comparative capabilities of all the available modules. In this first installment of his new Python column, "Charming Python," David Mertz briefly describes the most popular and useful XML-related Python modules, and points you to resources for downloading individual modules and reading more about them. This article will help you determine which modules are most appropriate for your specific task.
|
 |
Articles |
 |
01 Jun 2000 |
|
| |