Equivalent in Python?
Aahz
aahz at pythoncraft.com
Mon Apr 29 23:37:21 EDT 2002
In article <f7jz8.18268$Wd2.881746 at wagner.videotron.net>,
Vincent Foley <vinfoley at iquebec.com> wrote:
>
>What's the Python equivalient of Perl's "a"++; ?
There isn't any direct equivalent. Python strings don't have any kind
of increment magic associated with them, but you could create a class
that worked like this:
s = AutoIncrementString('a')
s.increment() # or even s.inc()
However, if you designed it do this:
s = AutoIncrementString('a')
s += 1
you'd get harsh comments from the vast majority of Python programmers.
Bad juju, mixing strings and numbers without explicit conversion.
--
Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/
"I used to have a .sig but I found it impossible to please everyone..." --SFJ
More information about the Python-list
mailing list