"Norman Khine" <[EMAIL PROTECTED]> wrote > name = title.lower().replace('/', '_').replace('?', > '_').replace('.', '') > return '_'.join(name.split()) > > Is there a way to have just one replace and so that:
Check out the string.maketrans() function and the translate method. Basically you do something like: table = string.maketrans('/?_','___') title = title.translate(table) Now I'm not sure how it will react to the translation mapping all three chars to the same result char, but it should work... HTH, -- Alan Gauld Author of the Learn to Program web site http://www.freenetpages.co.uk/hp/alan.gauld _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor