LWN.net Logo

Development

Choosing a ternary operator for Python

C and C++ programmers encounter the ternary operator early in their education. This operator, which in C syntax, looks like:

    <condition> ? <expression1> : <expression2>

evaluates to expression1 if (and only if) the given condition evaluates true; otherwise expression2 is chosen. The ternary operator is a compact representation of a common operation (choosing between two values), and it is a heavily-used feature in languages which provide it.

Python does not provide a ternary operator, much to the chagrin a subset of hackers who are otherwise very happy with the language. As a way of responding to years of requests, Python Benevolent Dictator For Life Guido van Rossum posted a proposal for a Pythonic ternary operator, and asked the community to get back to him with its opinion. To say that the discussion was active would be a substantial understatement; thousands of messages were posted discussing the merits of ternary operators, whether Python should have one, and what form it should take. The result was a revised version of PEP 308.

That proposal included a few possible forms for a Python ternary operator. The primary proposal was for this form:

    (if <cond>: <expr1> else: <expr2>)

This form is easily extended to four or more operands:

    (if <cond>: <expr1> elif <cond2>: <expr2> else: <expr3>)

Unusually for Python, the parentheses would be mandatory. For that reason, and the fact that the syntax looks a lot like the regular if/else control structure, not everybody was happy with this proposal. So a number of alternatives were floated as well. They range from the standard C syntax to variants like:

    <cond> and <expr1> else <expr2>
    <cond> then <expr1> else <expr2>
    <expr1> if <cond> else <expr2>
    cond(<cond>, <expr1>, <expr2>)
    <cond> ?? <expr1> || <expr2>
    <cond> -> <expr1> else <expr2>

If this were Perl, the language hackers would have probably just implemented all the possibilities and been done with it. But Python programmers like to have one accepted way of doing things, so a decision had to be made. A vote was held, and the results are now available.

No alternative won a clear majority of the 518 votes counted. The parenthesized syntax from the proposal got the most votes, but the C syntax was not far behind. The "no change" contingent was rather smaller, but very passionate in its arguments. The end result is that vote coordinator Raymond Hettinger has not chosen to certify a winning proposal as such. Instead. he is passing the results back to the Benevolent Dictator who, after all, has a rather larger vote than anybody else. As of this writing, Guido has not made his decision known.

Comments (5 posted)

System Applications

Audio Projects

ALSA 0.9.1 released

Version 0.9.1 of the ALSA collection of sound driver, library, utilities, and tools has been released. This is the first stable release in the 0.9 series.

Comments (none posted)

JACK 0.61.0 released

Version 0.61.0 of the JACK Audio Connection Kit is available. New features include in-process client support, bug fixes, and improved documentation.

Full Story (comments: none)

liblrdf 0.2.4 announced

Version 0.2.4 of librdf is available. "liblrdf is a library for handling RDF files describing LADSPA plugins, plus it can also do lightweight general RDF tasks." This version adds a pkgconfig file and bug fixes.

Full Story (comments: none)

Planet CCRMA at home

The Planet CCRMA project provides a collection of RPM packages for turning a Red-Hat based computer into an audio workstation. The latest change are as follows: "Added a preliminary version of a Planet CCRMA roadmap, it should help you identify potentially useful programs. This is just a first version, most probably incomplete, hopefully not very innacurate :-)"

Comments (none posted)

Database Software

SAP DB Version 7.4.03.14

Version 7.4.03.14 of SAP DB is available. See the Release Information for change information.

Comments (none posted)

Using Topic Maps to Extend Relational Databases (O'Reilly)

Marc de Graauw shows how to use XML topic maps with databases on O'Reilly. "Relational databases are great for storing structured data which conforms to a well-defined relational database schema. They are not so good at storing information that does not conform to such a schema. Since user requirements inevitably change, this means costly database upgrades."

Comments (3 posted)

Education

Linux in Education Report

Issue #91 of the Linux in Education Report is out. Topics include a report from the Lane Community College's Open Source Educational Group, putting a Linux lab into Logan High School, the Demo@Schools project, SkoleLinux, a table of equivalents / replacements / analogs of Windows software in Linux, a discussion on the limits of Open-source Software, setting up a computer lab for OS testing, the Linux in Education Spring Conference, and more.

Comments (none posted)

Electronics

gEDA News

The latest new software from the gEDA project includes Icarus Verilog development snapshot 20030308, and GTKWave 2.0.0pre3-20030304.

Comments (none posted)

Printing

GSview 4.32 beta release

Version 4.32 beta of GSview, a PostScript viewing program, has been announced. Changes include security fixes for compatibility with AFPL Ghostscript 8.00, Catalan, Russian and Slovak language support, and minor bug fixes.

Comments (none posted)

LinuxPrinting.org news

The latest news from LinuxPrinting.org includes the addition of a number of HP, Epson, and Minolta printers to the Foomatic printer support database.

Comments (none posted)

Web Site Development

Midgard Components Framework 1.0 released

Version 1.0 of Midgard Components Framework is now available under the GNU LGPL license. "MidCOM provides a framework for creating reusable and configurable components for web applications using the Midgard Content Management Framework."

Full Story (comments: none)

Quixote 0.6beta3

Version 0.6beta3 of Quixote, a Python-based web development framework, is available. Change information is in the source code.

Comments (none posted)

Zope Members News

The most recent headlines on the Zope Members News include: Zope at the CeBIT 2003 in Hannover!, MailBoxer 2.2.2 released, Initial Release of CSVFile Product, CJKSplitter v0.2, TextIndexNG 1.09 released, CMF 1.3.1 Released, CMFCollectorNG 0.20 final released, Update to the ieeditor addon, Silva Windows installer, and Initial release of RSessionDA.

Comments (none posted)

Improving mod_perl Sites' Performance: Part 8 (O'Reilly)

Stas Bekman continues his O'Reilly series on mod_perl tweaking with part 8. "In this article we continue talking about how to optimize your site for performance without touching code, buying new hardware or telling casts. A few simple httpd.conf configuration changes can improve the performance tremendously."

Comments (none posted)

Miscellaneous

The Mojolin Project

The first pre-release of the code for the Mojolin Project is available. Mojolin is a web-based system that connects job seekers with potential employers.

Full Story (comments: none)

The 802.11g standard -- IEEE (IBM developerWorks)

L. Victor Marks introduces 802.11g wireless networking on IBM's developerWorks. "The bid continues to improve the 802.11 standard to something that fulfills our wireless transmitting fantasies. Victor Marks shows us how 802.11g has shaped up, and how it's fareing in the race."

Comments (none posted)

Desktop Applications

Audio Applications

ladcca 0.3.1 released

Version 0.3.1 of LADCCA, the Linux Audio Developer's Configuration and Connection API, is available and features a few bug fixes. "LADCCA is a session management system for JACK and ALSA audio applications on GNU/Linux."

Full Story (comments: none)

swh-plugins 0.3.7 available

Version 0.3.7 of swh-plugins, an audio systhesis package, is available. This edition features changes to the gate code and the addition of a bandlimiting filter.

Full Story (comments: none)

Spiralsynth Modular 0.2.1

Version 0.2.1 of SpiralSynth Modular, "an object orientated music studio with an emphasis on live use", is out. Changes include a new GUI, midi note filtering, new plugin groups, more theming, a matrix pattern sequencer, bug fixes, and more.

Full Story (comments: none)

ecamegapedal 0.4.1 released

Version 0.4.1 of ecamegapedal, a real-time audio effects processor, has been released. Bugs have been fixed in the build process. See the release notes for more information.

Comments (none posted)

RTMix 0.7 released

Version 0.7 of RTMix is available. "RTMix is an open-source (GPL-licensed) software application designed to provide stable, user-friendly, standardized, and efficient performance interface that enables performer(s) to interact with both the computer and each other in the least obtrusive fashion." Many new features and fixes are included in this release.

Full Story (comments: none)

Desktop Environments

KDE-CVS-Digest for March 7, 2003

The March 7, 2003 edition of the KDE-CVS-Digest is out. Topics are summarized as: "KDevelop gets more templates, Quanta gets better action toolbars and Umbrello gets new code generators. A dummy KDE 3.2 release schedule. More merges from Safari to KHTML."

Comments (none posted)

Workrave 1.2.0 ''Stats'R'Us''

A new version of Workrave, a Gnome-based tool that helps people with Repetitive Strain Injuries (RSI), has been announced. "Workrave now keeps track of all your activity and allows you to browse through any date in history to see for how long you used the computer, how many keys you pressed, the distance your mouse moved, and many other statistical data."

Comments (none posted)

Eel and Nautilus 2.2.2 Released

FootNotes has an announcement for Eel and Nautilus 2.2.2. "Normally we don't anounce nautilus releases to mailing lists. "We won't bother," we say to ourselves, "people will find it eventually." But "eventually" won't cut it with this release.

It is too darned good.
"

Comments (none posted)

GNOME 2.2 Gains Muscle and Polish (eWeek)

eWeek reviews GNOME 2.2. "The latest upgrade of the GNOME Foundation's desktop environment offers users a spare and approachable graphical interface to Linux and similar operating systems that's matured noticeably since its last release."

Comments (none posted)

GNOME System Tools 0.24.0 is out!

FootNotes announces the latest GNOME Systems Tools release. "A new version of the GNOME System Tools has seen the light!, this is mainly a bugfix release, so no new features have been added."

Comments (none posted)

Interoperability

Samba 3.0alpha22 available

Version 3.0alpha22 of Samba is available. "The latest alpha snapshot of the SAMBA_3_0 cvs tree is available for download. It is being provided for testing purposes." The release notes are available here.

Comments (none posted)

Office Applications

The OpenOffice.org Community Council

The OpenOffice.org project has decided that the time has come to form a "community council" to guide its further development. The council is expected to be made up of nine members representing various parts of the project (and a seat for Sun Microsystems). It will make decisions on strategic planning (where OOo should be going) and resource allocation, represent the project to Sun and the public, and arbitrate disputes within the development community. There will be an online vote, starting March 14, on the council charter; read the announcement if you are interested in participating.

Full Story (comments: 1)

AbiWord Weekly News

Issues number 133 and 134 of the AbiWord Weekly News are available. The latest issue is summarized as: "Fixes to the Linux/PPC build comes in from one unknown hacker, while another name, Larin Hennessy, makes quite the noticeable splash. Snapping back to the release outline for AbiWord II: The Wrath of Dom results in a hard feature freeze. Finally, Hub knocks off two more posers on the Release HackDown for 1.0.5"

Comments (none posted)

Kernel Cousin GNUe

Issue #71 of Kernel Cousin GNUe is out with the latest GNU Enterprise development news. Topics include: Release plans and Case-Insensitive Queries, Multi-part delimited Stock-Keeping Units in gnue-sb, GNUe Tools users, Running GNUe Small Business, and GNUe Small Business vs. sql-ledger.

Comments (none posted)

LyX Development News

The March 6, 2003 edition of the LyX Development News is out, with news of LyX release 1.3.0 and other development work.

Comments (none posted)

Web Browsers

Galeon 1.3.3 released

Development version 1.3.3 of the lightweight Galeon browser has been announced. "This is the release many of you have been waiting for, it reintroduces the much wanted javascript etc. quick toggles. You're slowly running out of excuses if that has been your reason to stay with the stable 1.2.x releases ;)"

Comments (none posted)

mozillaZine

The latest mozillaZine topics include: Another Round of 1.3 Candidate Builds, Honesty Issues Dog Anonymous Donations Poll, 1.3 Candidate Builds Available for Testing, BBC News Examines Alternative Browsers, Xabyl 1.0 Alpha Released, Preferences Toolbar 2.2 Released, Mitchell Baker on Browser Innovation, Gecko and the Mozilla Project, and Camino 0.7 Released!.

Comments (none posted)

Miscellaneous

GnomeICU 0.99 release

FootNotes has an announcement for version 0.99 of Gnome ICU, an internet chat utility. "After months of hard work we have a new release. The main focus of this release was to get all of the features in place for 1.0. Only one BIG thing is missing: working, stable file transfer. All other ICQ features should be here."

Comments (none posted)

Languages and Tools

Caml

Caml Weekly News

The March 11, 2003 Caml Weekly News looks at Libraries in functional languages, ipv6, and Xcaml 0.0.1.

Full Story (comments: none)

The Caml Light / OCaml Hump

This week, the new software on The Caml Light / OCaml Hump includes: SKS; an OpenPGP keyserver, bibgrep; a bibtex file index and search utility, and CamlG4; a library for Objective Caml for performing SIMD parallel processing on PowerPC G4 processors.

Comments (none posted)

Java

Advanced Text Indexing with Lucene (O'Reilly)

Otis Gospodnetic introduces Lucene on O'Reilly. "Lucene is a free text-indexing and -searching API written in Java. To appreciate indexing techniques described later in this article, you need a basic understanding of Lucene's index structure. As I mentioned in the previous article in this series, a typical Lucene index is stored in a single directory in the filesystem on a hard disk."

Comments (none posted)

Using Hierarchical Data Sets with Aspire and Tomcat (O'Reilly)

Satya Komatineni discusses Hierarchical data sets on O'Reilly. "This article examines the structure of, and a Java API for, Hierarchical Data Sets. Unlike the XML Journal reference two years ago, you will now actually have a piece of executable code to use to start taking advantage of Hierarchical Data Sets."

Comments (none posted)

Lisp

Call for Macsyma code

A call for code has been issued for the Macsyma project. "Maxima is a computer algebra system written in Common Lisp. It is a descendant of DOE Macsyma, whose origins date back to the late 1960s at MIT." Thanks to Paolo Amoroso.

Full Story (comments: none)

Perl

Apocalypse 6

Larry Wall has posted Apocalypse 6, a look at how Perl 6 will handle subroutines. "Unlike regexes, Perl subroutines don't have a lot of historical cruft to get rid of. In fact, the basic problem with Perl 5's subroutines is that they're not crufty enough, so the cruft leaks out into user-defined code instead, by the Conservation of Cruft Principle. Perl 6 will let you migrate the cruft out of the user-defined code and back into the declarations where it belongs."

Comments (5 posted)

This week on Perl 6

The March 3, 2002 edition of This week on Perl 6 is available. Topics include: IMCC calling conventions, A couple of easy questions..., More on optimizing the JIT with IMCC, Parrot 0.0.10 freeze, Dan's plans, PSteve Peters' Patches Prevent Parrot Peeves, and Meanwhile, in perl6-language.

Comments (none posted)

March Perl Journal

The March 4, 2003 edition of the Perl Journal has been published. Topics include: "Fractal Images and Music With Perl, Writing Multilingual Sites With mod_perl and Template Toolkit, Perl in High Performance Computing Environments, Something for Nothing by Simon Cozens, Creating Perl Application Distributions by brian d foy, And more, including a review of Graphics Programming in Perl."

Comments (none posted)

PAR 0.65 released; need binary package contributions (use Perl)

Version 0.65 of PAR has been announced. "PAR is a cross between JAR and Perl2exe/PerlApp; this version marks significant improvements like automatic binary installation, POD stripping and 5.6.1 support."

Comments (none posted)

PHP

PHP Weekly Summary

Topics on this week's PHP Weekly Summary include: 64-bit compatibility, namespaces in ZE2, Apache2 and PHP, Extensions with Debian Woody, sqlite extension, and ZE fixes.

Comments (none posted)

Python

Dr. Dobb's Python-URL! for March 10, 2003

The Dr. Dobb's Python-URL is available with weekly news and links for the Python community.

Full Story (comments: none)

The Daily Python-URL

This week's Daily Python-URL article topics include: Slashback: Rocketry, Pythonation, Scoffing, Python in a Nutshell, Create declarative mini-languages, Metaclass programming in Python, Inside the RSS validator, and more.

Comments (none posted)

Wrap GObjects in Python (IBM developerWorks)

Ross Burton shows how to access C code from Python. "Learning how to wrap GTK+ C modules for use in Python will enable you to use a C-coded GObject in Python whenever you like, whether or not you're especially proficient in C."

Comments (none posted)

Ruby

The Ruby Garden

New topics on the Ruby Garden include: nil.method_missing (Objective-C behaviour) and propagating comparisons like Python.

Comments (none posted)

The Ruby Weekly News

Topics on this week's Ruby Weekly News include: Russian Ruby resource and Ruby Course, Test::Unit::Mock: Mock objects for testing with Test::Unit, PSE as Ruby module and an RAA question, OSCON, and "I'm to give short talk on ruby at work, anybody have material/outlines they can donate".

Comments (none posted)

Scheme

Scheme Weekly News

The March 10, 2003 edition of the Scheme Weekly News is available.

Full Story (comments: none)

Smalltalk

Squeak 3.4 released

Version 3.4 of Squeak has been released. "Squeak is a personal multimedia environment aimed at end-users of all ages, developers, authors, and teachers. Beneath its graphical user interface, it is powered by a descendant of the Smalltalk-80 language."

Full Story (comments: 1)

XML

Prototyping One-to-many Links with XSLT (O'Reilly)

Bob DuCharme covers linking and XSLT on O'Reilly. "In the ongoing debate about the future of linking, a key topic is the representation of one-to-many links. There are several ways to implement them, mostly by using JavaScript code to create pop-up menus, but the only standard way to represent them is W3C XLink extended links, and these have not caught on."

Comments (none posted)

Miscellaneous

Mono 0.23 Released

Version 0.23 of Mono, an open source implementation of the .NET Development Framework, has been released. "This is only a bug fix release, because we introduced an unfortunate bug in reflection in version 0.22. This should fix compilation for many of you that had problems."

Comments (none posted)

Jext Plugins

There is a new plugins page on the Jext programmer's editor site. A number of plugin extensions to the editor are listed.

Comments (none posted)

Page editor: Forrest Cook
Next page: Linux in the news>>

Copyright © 2003, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.