Skip to content

Instantly share code, notes, and snippets.

@jheasly
Created June 12, 2012 20:14
Show Gist options
  • Save jheasly/2919870 to your computer and use it in GitHub Desktop.
Save jheasly/2919870 to your computer and use it in GitHub Desktop.
A section of topadsFeed.py
def removeNonASCII(file):
""" remove non-ASCII chars from file, after making a bakup first
"""
fileBak = "%s.bak" % (file)
err = os.system("cp -p %s %s" % (file, fileBak))
if err:
return
fout = open(fileBak, 'w')
for line in fileinput.input(file):
fout.write(re.sub(r'[\x80-\xff]', '', line))
fout.close()
@jheasly
Copy link
Author

jheasly commented Jun 12, 2012

Seems like since you're setting a value to err on Line 5, then if err on Line 6 always evaluates to True and thus always exits on the return ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment