Incrementing a string

John Velman velman at cox.net
Thu Sep 16 13:58:26 EDT 2004


Thanks to everyone who responded!  I've learned a good deal by reading
through the solutions.  Don't know which one I'll use yet (or perhaps I'll
use something suggested by them), but these take me another step toward
'thinking in Python'.  Also, I might add, it's really hard to know of all
the machinery that is available --- there is so much of it.  I now know
about the itertools module, for example.

Kjetil Torgrim Homme asked why not just make the labels L1, L2, ..., Paul
Foley proposed similarly: label1, label2, ..., and also suggested that if
$label="one" it would make sense for $label++ to be "two".

Either of these would work (although "one","two",... would be yet a
different programming problem).  I prefer my initial choice because the
labels will be used interactively, and I prefer to be able to do
everything from the keyboard. It's easier for me to type "aq" than "L42".
I'm a pretty good touch typist as far as lower case letters go, but
usually have to look at the keyboard to type numerals.  So "m" is
preferable to "L12" but, to me, there isn't much difference between
typing "l12" and "label12".

I think some of the proposed solutions would make it easy to taylor the
kind of label as a user preference if I ever get this application to the
point that I think someone else might be interested in using it.

And yes, I think I'm going to enjoy Python.

Best,

John Velman



More information about the Python-list mailing list