Hacker News new | past | comments | ask | show | jobs | submit login

Strings are unicode. Bytes are encoded data.

With Python 2 strings you have to be proactive about it and - always use u"" unless you know what you're doing - segregate non-unicode data to boundaries by decode()ing early and encode()ing late, or you're guaranteed to shoot yourself in the foot sooner or later

but if you do it it's quite smooth sailing.

Also,

    #/usr/bin/env python
    # -*- encoding: utf-8 -*-
helps a lot.

All that just brings you closer to Python 3 anyway and really helps when using 2to3.




Agreed, however I've run in to compatibility issues with 3 a few times and so resolved to stick w/ 2, deal with the text parsing issues myself, keep the libraries I like and leave the ops team alone.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: