Skip to content
0:00 / 0:00

#unicode#python2#python3

Pragmatic Unicode, or, How do I stop the pain?

Next Day Video

68K subscribers • 15 videos on Hallway

YouTube
  • Recommended by 2 people: 2 on Hacker News.
  • A classic. People kept recommending it from 2015 to 2019.
  • Presented by Ned Batchelder, Python core contributor

Intermediate. Assumes working knowledge.

80K views14 years ago2 recommendations

Programming languagesTools and practicePythonSimplicity and complexity

Ned Batchelder explains how Unicode and byte strings work in Python, introducing the Unicode sandwich strategy to prevent encoding errors.

Ned Batchelder Python has great Unicode support, but it's still your responsibility to handle it properly. I'll do a quick overview of what Unicode is, but only enough to get your program working properly. I'll describe strategies to make your code

Why it's here

2 people recommend this

What people say. Highly recommended as the definitive, clearest explanation of how to handle Unicode and bytes without pain.

jteppinetteon Hacker News • Recommends

On ““Python's batteries are leaking””

You have to invest some time in understanding how strings (byte strings and unicode) work in Python. I put this off for way too long. After A TON OF PAIN I decided to put the time in to watch the talk "Pragmatic Unicode, or, How do I stop the pain?"0 by Ned Batchelder and it all just clicked. Now, I make unicode sandwiches like a boss. 0 link to this video

ptxon Hacker News • Recommends

On “Why Perl Didn't Win”

…string), give UnicodeDecodeError in Python 2 or garbage data in Perl 5.8. Ned Batchelder gave an excellent talk1 that explains how the Python 3 approach to Unicode works. I think it makes a lot more sense once you understand it; the Python 2 way was clearly broken, and it looks like Perl 5 has the same problem but hides it better. 0 link 1 link to this video…

ptxon Hacker News • Mentions

On “Learn Python the Hard Way”

…well to Python 2 code as well. But someone starting with Python 2 can easily be confused about the concept (because the language is confused) and will have a hard time getting things to work correctly. For example, the book recommends that people "from another country" set their source encoding to UTF-8 – good luck printing things on Windows. 1 link to this video…

thanksgivingon Hacker News • Mentions

On “Numpy: Plan for dropping Python 2.7 support”

I don't know the details (because I don't understand unicode) but I am not sure what you said is possible. But to me ASCII seems like a hindrance. ``` fmt.Println("Hello, 世界") ``` This line of go lang looks beautiful. I bet they never have to worry about bytes vs Unicode. Here is python... link to this video I'll add one more assertion to the list. People are born and people die. It is not fair for us to impose our mistakes and sins to the next generation. With that being said, my thought was simply all the scripts that are in python (even the simple build for Firefox was python 2 only last time I checked). The way forward for anyone new to python is for us to tell them: Python 2 doesn't matter. Don't…