How do i remove trailing whitespace in python code , using python script
<p>something like :</p>

<pre>
#!/usr/bin/env python
import fileinput
for lines in fileinput.FileInput("test.txt", inplace=1):    
    lines = lines.strip()
    if lines == '': continue
    print lines
</pre>

<p>but nothing is being printed on stdout</p>

<p>assuming some string named foo, to remove leading white space:</p>

<pre>
>>> foo.lstrip()
to remove trailing whitespace:
>>> foo.rstrip()
to remove both lead and trailing whitespace:
>>> foo.strip()
</pre>
