> On May 4, 2015 2:17 AM, "anupama srinivas murthy" < > anupama.2312.bm...@gmail.com> wrote: > >> Hello, >> >> My python code needs to run on versions 2.7 to 3.4. To use stringio >> function as appropriate, the code i use is; >> >> if sys.version < '3': >> dictionary = io.StringIO(u"""\n""".join(english_words)) >> else: >> dictionary = io.StringIO("""\n""".join(english_words)) >> >> The code runs fine on all versions mentioned above except for 3.2 where i >> get the error: >> dictionary = io.StringIO(u"""\n""".join(english_words)) >> ^ >> SyntaxError: invalid syntax >> >> How can I solve the issue? >> >> Thank you >> Anupama >> >> >
On 4 May 2015 at 12:48, Reuben <reuben.dl...@gmail.com> wrote: Did you import correct library? Thank you for asking Yes. I made a new modification and the code now runs fine on python 3.2 as well. I replaced; dictionary = io.StringIO(u"""\n""".join(english_words)) with dictionary = io.StringIO(unicode('\n').join(english_words)) However, i do not understand why it works fine now _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor