Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #95210
| References | <D1ECF359.10CC65%Dwight@GoldWinde.com> <55C790D3.3040906@gmail.com> |
|---|---|
| Date | 2015-08-10 11:27 +1000 |
| Subject | Re: Is Django the way to go for a newbie? |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.22.1439170072.3627.python-list@python.org> (permalink) |
On Mon, Aug 10, 2015 at 3:41 AM, Michael Torrie <torriem@gmail.com> wrote:
> Web development is very a very hard problem, largely because it involves
> quite a few different domain-specific languages that you have to be
> proficient in...
>
> In this area, node.js is getting very popular. I don't care much for
> javascript but using it on the server as well as the web browser itself
> reduced the number of languages you have to know by one.
There's another thing you absolutely have to know when you do web
development, and that's i18n. This is why I don't recommend Node.js
for server-side work - because Python's Unicode support is better than
JS's. Stick with Python (and avoid Python 2 on Windows) and you get
great Unicode support. Do anything in JavaScript/ECMAScript and you
get UTF-16 as the official representation. What's the length of the
string "Hello, world"?
>>> len("Hello, world")
12
> "Hello, world".length
12
So far, so good. What if those weren't ASCII characters?
>>> len("π·π΄π»π»πΎ, π
πΎπ
π»π³")
12
(That's Python 3. In Python 2, you'd need to put a u"" prefix on the
string, but it's otherwise the same, modulo the Windows narrow-build
issue.)
> "π·π΄π»π»πΎ, π
πΎπ
π»π³".length
22
ECMAScript stipulates that strings are not codepoints, but UTF-16 code
units, so whenever you work with astral characters (which includes a
lot of emoticons, Chinese characters, and other symbols that your end
users *will* use), they'll get things wrong. The length of the string
counts astral characters twice; indexing/slicing can take half of a
character; any manipulation at all could corrupt your data.
So, use Python for all your text processing. Life's better that way.
ChrisA
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Is Django the way to go for a newbie? Chris Angelico <rosuav@gmail.com> - 2015-08-10 11:27 +1000
Re: Is Django the way to go for a newbie? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-08-10 13:58 +0200
Re: Is Django the way to go for a newbie? Chris Angelico <rosuav@gmail.com> - 2015-08-10 22:57 +1000
csiph-web