String concatenation

Peter Otten __peter__ at web.de
Sat Apr 3 03:20:14 EST 2004


Leif B. Kristensen wrote:

> The "feature" is also submitted to the KDE bugtrack, see
> <url:http://bugs.kde.org/show_bug.cgi?id=60971>.
> 
> Apparently, "real programmers" don't cut and paste code samples from
> KNode. Go figure.

I doubt that KNode is to blame. The problem you encountered occured
to me only sporadically. Therefore I guess that the culprit is elsewhere in
the toolchain.

In the meantime, whenever an apparent whitespace generates a syntax error:

<clean160.py>
#!/usr/bin/env python
import string, sys, os

transTable = string.maketrans(chr(160), " ")

if __name__ == "__main__":
    for filename in sys.argv[1:]:
        s = file(filename).read()
        if chr(160) in s:
            print "cleaning", filename
            os.rename(filename, filename + ".160")
            file(filename, "w").write(s.translate(transTable))
        else:
            print "skipping", filename
<clean160.py>

Peter

PS: I'm not sure if the above reaches you without those vicious blanks, but
I'm confident :-)



More information about the Python-list mailing list