I'm writing a script to convert Latex commands to bbcode by using the str.replace function and I'm confused as to why this works:
if '\chapter' in line: line = line.replace('\chapter{', '[b][u]') line = line.replace('}', '[/b][/u]') but this doesn't: if '\title' in line: line = line.replace('\title{', '[size=150][b]') line = line.replace('}', '[/b][/size]') Here is the short version of the script: infile = open('test.tex') outfilename = infile.name.partition('.')[0] + '.bbcode' outfile = open(outfilename, 'w') for line in infile: if '\title' in line: line = line.replace('\title{', '[size=150][b]') line = line.replace('}', '[/b][/size]\n') if '\chapter' in line: line = line.replace('\chapter{', '[b][u]') line = line.replace('}', '[/u][/b]') outfile.write(line) infile.close() outfile.close() -- http://mail.python.org/mailman/listinfo/python-list