On 09.02.2013 12:04, Joshua Robinson wrote: > Hi *Monte-Pythons*, > > x = "this is a simple : text: that has colon" > s = x.replace(string.punctuation, ""); OR > s = x.replace(string.punctuation, ""); > print x # 'this is a simple : text: that has colon' > # The colon is still in the text !!!! > > Is this a bug or am I doing something wrong ?
The latter. str.replace() only replaces complete substrings, not single character occurences of the given pattern. That is "foo".replace("foo", "bar") == "bar" "foofoo".replace("foo", "bar") == "barbar" "foofoo".replace("fo", "bar") == "barobaro" "foofoo".replace("abcdef", "bar") == "foofoo" Regards, Johannes -- >> Wo hattest Du das Beben nochmal GENAU vorhergesagt? > Zumindest nicht öffentlich! Ah, der neueste und bis heute genialste Streich unsere großen Kosmologen: Die Geheim-Vorhersage. - Karl Kaos über Rüdiger Thomas in dsa <hidbv3$om2$1...@speranza.aioe.org> -- http://mail.python.org/mailman/listinfo/python-list