[Tutor] shlex.split if there is an apostrophe in the string?

Sean Carolan scarolan at gmail.com
Fri Jan 7 20:22:23 CET 2011


I'm practicing manipulating data with a text file.  I'm trying to use
shlex.split to break up each line, which works great until it gets to
the first apostrophe:

fin = open('huckfinn.txt')
startstring = 'START OF THIS PROJECT'

for line in fin:
    print line
    words = shlex.split(line)

This is the line is where it's choking, complaining that there is no
closing quote:

YOU don't know about me without you have read a book by the name of The

How can I get shlex.split to ignore single apostrophes such as the one above?


More information about the Tutor mailing list