Ok... this is *really* the last time.

I don't know why I was using a regular expression, when string.replace
would have done just as well. Here's my final version of the external
method. I *promise* I won't change it again.

Of course, the simplest version would be

from string import replace
def D_date(datestring):
     datestring=replace(datestring, 'Monday', 'Montag')
     datestring=replace(datestring, 'Tuesday', 'Dienstag')
     # und so weiter

However, this would be slower to execute than using "reduce", as below.

from string import replace

# you can remove lines where the words are the same in both languages

for e,d in replacements.items():
        eval("lambda x: replace(x, '%s', '%s')" % (e, d)))
del replacements

def D_date(datestring):
    return reduce(lambda x,y: y(x), replace_fns, datestring)


Steve Alexander
Software Engineer
Cat-Box limited

Zope maillist  -  [EMAIL PROTECTED]
**   No cross posts or HTML encoding!  **
(Related lists - 
 http://lists.zope.org/mailman/listinfo/zope-dev )

Reply via email to