E121 and E127 and wrapping unicode quoted strings #129

robhudson opened this Issue Oct 12, 2012 · 4 comments


None yet
3 participants

I'm not sure exactly what pep8 thinks of this but I find it is something that I don't intend to change in my code, so I thought I'd bring it up here and let you decide.

I have code like this:

some_method_call(u'A very long string more than 80 chars in length that needs '
                  'to be wrapped.')

If I put the u on the 2nd line it's ok, but I'm not sure this is really necessary.


I concur with @robhudson


florentx commented Oct 17, 2012

The recommended way is to prefix every string with a u.
Every time you concatenate implicitly unicode and bytes, a pony dies.

If you're not convinced do the same in Python 3, or try one of these in Python 2:

print (u"café "
        "ou thé")

print (u"caf\xe9 "
        "ou th\xe9")

ups, I misread @robhudson 's code. Indeed, concatenating strings of different types is not ok. Sorry about that.

I'm convinced now. Closing, as this works fine otherwise.

Thanks for the knowledge share! 👍

robhudson closed this Oct 17, 2012

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