ReXX Style translate() function for strings ?

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


Hello,

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
name)

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, 
http://users.comlab.ox.ac.uk/ian.collier/Docs/rexx_ref/F/BI

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.

TIA

P. Adhia



More information about the Python-list mailing list