ReXX Style translate() function for strings ?

P Adhia padhia at
Tue Oct 30 21:57:40 CET 2001


I am a newbie to python, and remain impressed with the power of the
language overall. There are however some little features that I am
used to in ReXX (default scripting language for mainframes) that I
could not find in python.

ReXX has a translate() function that is much more powerful (and I
think coule be a nice addition to python; of course with a different

e.g. in ReXX, to change a date from yyyymmdd to mm/dd/yyyy is
trivially simple,
new_date = Translate('56/78/1234', old_date, '12345678')

for formal syntax refert to,

Python's l/r/strip() functions always remove white spaces --
corresponding ReXX functions (actually only one) has a optional
argument that defines what character to strip. e.g. removing leading
'0' from a number, punctualtion characters etc.

If such functionality is trivial in python, I'll appreciate any new
addition to my growing python knowledge.


P. Adhia

More information about the Python-list mailing list