Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Unsung Python modules

0 views
Skip to first unread message

Andrew Kuchling

unread,
Dec 14, 2001, 11:31:56 AM12/14/01
to
There are some Python modules that deserve to be more widely known
outside of the Python community, because they're such handy
timesavers. My list of modules that don't get enough publicity would
include:

* The Python Imaging Library, which reads and writes a large number of
different image formats and can perform a number of different
operations on images. I find it indispensible for writing little
utility scripts that resize all the images in a directory or
generate an HTML image gallery.

* Reportlab, for generating PDF files: I can't believe that people
would wrestle C code for pdflib when they could just write Python
code.

* PyQt/PyKDE, which doesn't seem to get much respect in the KDE
community. (Maybe my perception is wrong?)

* Perhaps also the ZODB, as it's just so neat and convenient to use,
but it's also quite Python-specific.

What's your favorite unsung module?

--amk (www.amk.ca)
Oh, those are my subconscious thoughts. I shouldn't listen to them too
hard if I were you; I'm not all that proud of some of them.
-- The Doctor, in "The Time Monster"

Scherer, Bill

unread,
Dec 14, 2001, 11:43:50 AM12/14/01
to
On 14 Dec 2001, Andrew Kuchling wrote:

> There are some Python modules that deserve to be more widely known
> outside of the Python community, because they're such handy
> timesavers. My list of modules that don't get enough publicity would
> include:
>

<snip>

> * Reportlab, for generating PDF files: I can't believe that people
> would wrestle C code for pdflib when they could just write Python
> code.

I just started using Reportlab. It's absolutley fantastic. My
project manager was astounded by the report quality; he said "I
can't believe Python can produce a report that looks that good."


<snip>


> What's your favorite unsung module?

Queue, and Pyxie. Queue is so handy for many tasks when
multithreaded. Pyxie is the easiest way I've yet found to deal
with xml, both parsing and generating.

--
Bill.Scherer at Verizon Wireless
RHCE 807101044903581


Sean 'Shaleh' Perry

unread,
Dec 14, 2001, 11:58:05 AM12/14/01
to
> * PyQt/PyKDE, which doesn't seem to get much respect in the KDE
> community. (Maybe my perception is wrong?)
>

last I looked, pyKDE was still in the 1.x KDE days when KDE is about to enter
3.0.

Tim Hammerquist

unread,
Dec 14, 2001, 12:57:54 PM12/14/01
to
Andrew Kuchling <akuc...@mems-exchange.org> graced us by uttering:

> What's your favorite unsung module?

1) readline (optional built-in)
2) xreadlines

Two similarly named but unrelated modules have made my whole life
much easier. =)

Tim Hammerquist
--
relaxen und watchen das blinkenlichten.

Erik Max Francis

unread,
Dec 14, 2001, 1:41:59 PM12/14/01
to
Andrew Kuchling wrote:

> What's your favorite unsung module?

Sing with me: asyncore/asynchat, asyncore/asynchat.

--
Erik Max Francis / m...@alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Laws are silent in time of war.
\__/ Cicero
Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
An Esperanto reference for English speakers.

Skip Montanaro

unread,
Dec 14, 2001, 1:50:12 PM12/14/01
to

Tim> 1) readline (optional built-in)
Tim> 2) xreadlines

Tim> Two similarly named but unrelated modules have made my whole life
Tim> much easier. =)

I agree on the readline module (don't have a lot of need to text file
processing that sys.stdin.readlines() won't handle). It seems like I've
travelled back to the dark ages whenever I have to use Python without
readline or a "real" Bourne shell. Being able to recall a line or two from
an interactive session from a few minutes before (or a few days before)
makes day-to-day interaction with these tools so much easier. Readline gets
slammed for being a bloated pig, but it is a highly useful bloated
pig... ;-)

--
Skip Montanaro (sk...@pobox.com - http://www.mojam.com/)

Scherer, Bill

unread,
Dec 14, 2001, 2:25:08 PM12/14/01
to
On 14 Dec 2001, Andrew Kuchling wrote:

> What's your favorite unsung module?

I think anygui will become one. While not the interface (yet)
for gui's of exacting detail, for the more mundane gui it's quite
sufficient. My first gui with it ran without change under Python
on Linux and windows, and under Jython too. That's so cool.

Justin Sheehy

unread,
Dec 14, 2001, 2:13:15 PM12/14/01
to
Skip Montanaro <sk...@pobox.com> writes:

> I agree on the readline module (don't have a lot of need to text file
> processing that sys.stdin.readlines() won't handle). It seems like I've
> travelled back to the dark ages whenever I have to use Python without
> readline or a "real" Bourne shell. Being able to recall a line or two from
> an interactive session from a few minutes before (or a few days before)
> makes day-to-day interaction with these tools so much easier.

One reason that a lot of people might not think of this is that it's
not needed if you're using Python's interactive mode in an emacs
inferior shell buffer alongside Python-mode. Emacs takes care of the
history for you, regardless of readline. (Being able to send
arbitrary sections of code from the editor into the interactive
interpreter is also very important to me.)

I like this behavior so much that I will often use Emacs and
python-mode even when all I wanted was some interactive experimentation.

"Scherer, Bill" <Bill.S...@VerizonWireless.com> writes:

> Queue is so handy for many tasks when multithreaded.

Seconded. I use Queue very heavily in many different systems.

-Justin

Chris Barker

unread,
Dec 14, 2001, 3:56:48 PM12/14/01
to
Andrew Kuchling wrote:

> What's your favorite unsung module?

Numeric., although it has been sung (so has PIL). I do think it is
underutilized. Most folks seem to think it is "overkill" unless you are
doing serious number crunching (which I do), but I think is is very
useful even if you are working with small enough data sets that the
performance gains don't buy you anything. Being able to work with arrays
of Numbers (N-d arrays, no less) without all those loops, (or maps, or
list comprehension's) is just too nice!

Also, slicing arrays of greater than 1 dimension is often indispensable.

-Chris


--
Christopher Barker,
Ph.D.
ChrisH...@attbi.net --- --- ---
---@@ -----@@ -----@@
------@@@ ------@@@ ------@@@
Oil Spill Modeling ------ @ ------ @ ------ @
Water Resources Engineering ------- --------- --------
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------

Tim Hammerquist

unread,
Dec 14, 2001, 5:28:01 PM12/14/01
to
Skip Montanaro <sk...@pobox.com> graced us by uttering:

>
> Tim> 1) readline (optional built-in)
> Tim> 2) xreadlines
>
> Tim> Two similarly named but unrelated modules have made my
> Tim> whole life much easier. =)

>
> I agree on the readline module (don't have a lot of need to text
> file processing that sys.stdin.readlines() won't handle).

Well, here's the evolution of the textfile iteration:

# Incarnation 1
while 1:
line = fh.readline()
if not line:
break
process(line)

# Incarnation 2
for line in fh.xreadlines(): # same interface as xreadlines mod
process(line)

# Incarnation 3 (py2.2+)
for line in fh:
process(line)

Python's textfile iteration structures improved by orders of
magnitude with each step. Sure, sys.stdin.readlines() will do until
I have to parse a daemon log or flat text db; then there's no good
reason or even advantage to loading the whole file in memory at once.

> It seems like I've travelled back to the dark ages whenever I have
> to use Python without readline or a "real" Bourne shell. Being
> able to recall a line or two from an interactive session from a few
> minutes before (or a few days before) makes day-to-day interaction
> with these tools so much easier. Readline gets slammed for being a
> bloated pig, but it is a highly useful bloated pig... ;-)

Agreed! =)

Tim Hammerquist
--
Tell me -- How's your love life? Killed any girlfriends
recently? Or sentenced any more of them to Hell?
-- Desire to Morpheus, The Sandman

J.Jacob

unread,
Dec 14, 2001, 8:27:56 PM12/14/01
to
[amk]

>
> What's your favorite unsung module?
>

Besides the ones you mention i would like to add pygame. It can sing
itself be cause it has sound too !
It is the best thing if have found to easily do fast graphics, just 2D
style with pixel perfect (.GIF or .BMP or whatever) images and still
100 frames per second. Not the ugly realtime computer rendered 3D
stuff, but it can do openGL too, didnt test it myself.

You can make a game with pygame but also anythin else that needs to do
things with .GIFs moving around your screen.

Makes SDL available for Python programmers (try SDL in C, argh:)

phil hunt

unread,
Dec 14, 2001, 9:30:50 PM12/14/01
to
On 14 Dec 2001 11:31:56 -0500, Andrew Kuchling <akuc...@mems-exchange.org> wrote:
>There are some Python modules that deserve to be more widely known
>outside of the Python community, because they're such handy
>timesavers. My list of modules that don't get enough publicity would
>include:
>
>* The Python Imaging Library, which reads and writes a large number of
> different image formats and can perform a number of different
> operations on images. I find it indispensible for writing little
> utility scripts that resize all the images in a directory or
> generate an HTML image gallery.
>
>* Reportlab, for generating PDF files: I can't believe that people
> would wrestle C code for pdflib when they could just write Python
> code.
>
>* PyQt/PyKDE, which doesn't seem to get much respect in the KDE
> community. (Maybe my perception is wrong?)
>
>* Perhaps also the ZODB, as it's just so neat and convenient to use,
> but it's also quite Python-specific.
>
>What's your favorite unsung module?

I quite like the SPARK parsing framework.

--
*** Philip Hunt *** ph...@comuno.freeserve.co.uk ***

Andrew Dalke

unread,
Dec 14, 2001, 10:27:36 PM12/14/01
to
phil hunt:

>I quite like the SPARK parsing framework.

Seconded!

I also like mxTextTools.

(Why yes, I do do a lot of parsing -- why do you ask?)

Andrew

jason petrone

unread,
Dec 14, 2001, 12:47:02 PM12/14/01
to
Andrew Kuchling <akuc...@mems-exchange.org> wrote:
> What's your favorite unsung module?

I'm unsure what counts, but if PIL is considered unsung, I suppose I can
claim Numeric as my favorite module.

With Numeric I can use python for Real Work. Who needs Mathematica? Who
cares about Matlab? I have python+numeric+gnuplot.

Also, I love VIM's embedded python interpreter. I use xemacs occasionally for
english writing(as opposed to code). My .emacs file is almost 400 lines of
custom elisp. Thankfully customization of VIM doesn't require thinking
polish-- I can just write python code to do the heavy stuff.

Now if only my window manager(sawfish) spoke python instead of lisp...

jp

Michael Hudson

unread,
Dec 15, 2001, 8:33:03 AM12/15/01
to
Justin Sheehy <jus...@iago.org> writes:

> One reason that a lot of people might not think of this is that it's
> not needed if you're using Python's interactive mode in an emacs
> inferior shell buffer alongside Python-mode.

Can you get completion in python-mode? Or multi-line editing?

Cheers,
M.

--
... so the notion that it is meaningful to pass pointers to memory
objects into which any random function may write random values
without having a clue where they point, has _not_ been debunked as
the sheer idiocy it really is. -- Erik Naggum, comp.lang.lisp

Arthur Siegel

unread,
Dec 15, 2001, 10:15:56 AM12/15/01
to
>>>Andrew Kuchling <akuc...@mems-exchange.org> wrote:
> >What's your favorite unsung module?

jason writes -

> ...I suppose I can claim Numeric as my favorite module.

>With Numeric I can use python for Real Work. Who needs Mathematica? Who
>cares about Matlab? I have python+numeric+gnuplot.

My focus being on Python as an educational tool (my own education, first
off)
I would second Jason's sentiments on Numeric. A math education in a box.

And despite my disagreement with their team on core Python language design
issues, I am a VPython lover. I experience it as native Python brought into
the visual realm. Which is its intent, realized.

Art


Justin Sheehy

unread,
Dec 15, 2001, 2:56:10 PM12/15/01
to
Michael Hudson <m...@python.net> writes:

>> One reason that a lot of people might not think of this is that it's
>> not needed if you're using Python's interactive mode in an emacs
>> inferior shell buffer alongside Python-mode.
>
> Can you get completion in python-mode? Or multi-line editing?

Not in the same way that you can from readline.

I get completion via emacs' dynamic abbrevs, which are wonderful but
complete mainly based on the contents of current buffers. For
completion of names in my own code or code that I have loaded into
another buffer somewhere, this works beautifully.

I haven't needed multi-line editing exactly, since I'm already inside
an editor. If I want to redo an earlier action slightly differently,
I just type or modify it in an editor buffer and have python-mode
evaluate that block.

I certainly wouldn't argue that readline is useless. However,
python-mode provides different yet strongly overlapping functionality
and thus a python-mode user is much less likely to feel the need for
readline behavior.

-Justin

Tim Hammerquist

unread,
Dec 15, 2001, 4:22:53 PM12/15/01
to
Tim Hammerquist <t...@vegeta.ath.cx> graced us by uttering:

> Skip Montanaro <sk...@pobox.com> graced us by uttering:
>> I agree on the readline module (don't have a lot of need to text
>> file processing that sys.stdin.readlines() won't handle).
>
> ... Sure, sys.stdin.readlines() will do until I have to parse a

> daemon log or flat text db; then there's no good reason or even
> advantage to loading the whole file in memory at once.

I found an excellent example of this in the course of almost crashing
my computer:

Using kpackage I tried to get the list of files included in the
mozilla-0.9.5 rpm that came with my Mandrake 7.2 distro. There were
a lot of files. Not to put too find a point on it, but if I hadn't
doubled the recommended size of my swap partition, kpackage would've
crashed the machine!

This is no big deal for the command-line rpm because it iterates over
the filenames as it reaches them, and doesn't have to store them a
single, huge memory glob.

...which is why:

for x in fileobject.xreadlines():
...

...is more scalable than:

for x in fileobject.readlines():
...

...and isn't scalability the buzzword that everyone drops when
promoting Python? =)

Tim Hammerquist
--
The biggest problem with communication is the illusion that it has occurred.

Syver Enstad

unread,
Dec 15, 2001, 8:11:02 PM12/15/01
to
jason petrone <j...@NOSPAMdemonseed.net> writes:

> My .emacs file is almost 400
> lines of
>
> custom elisp. Thankfully customization of VIM doesn't require
> thinking
>
> polish-- I can just write python code to do the heavy stuff.

You'll be pleased to know that a python interface to emacs now exists,
pymacs. I use it myself and have written all of my recent extensions
in python instead of elisp.


--

Vennlig hilsen

Syver Enstad

Aahz Maruch

unread,
Dec 20, 2001, 10:59:19 PM12/20/01
to
In article <3dsnad2...@ute.mems-exchange.org>,

Andrew Kuchling <akuc...@mems-exchange.org> wrote:
>
>What's your favorite unsung module?

Queue. This should be tattooed on the forehead of every thread
programmer.
--
--- Aahz <*> (Copyright 2001 by aa...@pobox.com)

Hugs and backrubs -- I break Rule 6 http://www.rahul.net/aahz/
Androgynous poly kinky vanilla queer het Pythonista

Tenth Virtual Anniversary: 11 days and counting

François Granger

unread,
Dec 21, 2001, 2:25:26 AM12/21/01
to
Scherer, Bill <Bill.S...@VerizonWireless.com> wrote:

> On 14 Dec 2001, Andrew Kuchling wrote:
>
> > What's your favorite unsung module?
>
> I think anygui will become one. While not the interface (yet)
> for gui's of exacting detail, for the more mundane gui it's quite
> sufficient. My first gui with it ran without change under Python
> on Linux and windows, and under Jython too. That's so cool.

A really cool one. And run on MacOS like a charm.

--
La majorité à toujours tort car elle est composée d'imbéciles.
La minorité aussi, mais moins nombreux...
- Léo Campion - cité pas Noëlle Adam

0 new messages