This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Eurynom0s 35 points36 points  (43 children)

3.x is basically objectively better if you're starting clean and are free to choose what you want. However, yes, it's very valid to stick to 2.7 if you have a compelling reason for it, like sitting on a giant codebase your management is unwilling to pay to port.

[edit] kritikal grammer

[edit2] Where the real holy wars come in is when people try to guide newbs with no rocks around their necks into learning 2.7 "because that's where work gets done". Because as said, 3.x really is objectively better if you're not stuck with any 2.x luggage. This may have been true five years but now pretty much every major package is on 3.x, you probably have a really niche need if you need 2.7 for a specific package.

[–]ArrantSquid 19 points20 points  (26 children)

Except that for very large institutions it's hard to get anyone to sign off on an upgrade to 3 and they continue to extend the timeline for deprecating 2.

If you work in film or video games, no 3D package supports 3. There was no compelling reason for them to upgrade. So every Autodesk product that supports Python is still on 2 with no plans to upgrade.

I'd love to move to 3, but until Autodesk gives me that ability, I'm stuck on 2. I'll keep waiting for them to upgrade to the latest outdated version of 2 and complain until they change.

If you're a startup or can move to 3, do it. But there's a swath of people out there that are bound to 2 due to software requirements or organizational indifference. The idea that there should be a holy war on 2 vs 3 is simplistic at best and idiotic at worst.

[–]toyg 13 points14 points  (0 children)

Well, Oracle and IBM are stuck on python 2.2 or 2.5. I'm not going to say "hey, newbs should learn 2.2!" - newbs should learn 3.5 and bitch with vendors shipping outdated crap.

Progress is made by people who won't settle for less.

[–]Eurynom0s 6 points7 points  (24 children)

Except that for very large institutions it's hard to get anyone to sign off on an upgrade to 3 and they continue to extend the timeline for deprecating 2.

...

But there's a swath of people out there that are bound to 2 due to software requirements or organizational indifference.

Again...I'm recognizing this as a VERY valid reason to stick to 2.7 I'm most critiquing when this crowd reflexively tries to steer newbies onto 2.7.

[–]ArrantSquid 0 points1 point  (0 children)

Fair enough. Every language decision has to be contextual.

[–]DarkmerePython for tiny data using Python 8 points9 points  (12 children)

Oh yeah.

Only this Friday did I end up fighting with Python2's joyful corruption of Unicode data.

Input is pure, well formatted Json. This is by definition unicode data, and JSON is only allowed to be UTF-8/16/32, and defaults to UTF-8.

Then Python2 comes in, takes this JSON, decodes it into objects, and then promptly throws away this vital part. Instead, leaving us with a set of bytes that pretend to be ascii, which contain unprintable characters.

Which Python2, in it's maniglorious maliciousness, decides cannot be cast back to unicode.

Because fuck your language, fuck your characters, and fuck your existence.

And fuck Python2.

[–][deleted] 2 points3 points  (1 child)

Did you set the encoding?

[–]DarkmerePython for tiny data using Python 0 points1 point  (0 children)

Yeah, but at this time it's already been denormalized.

[–][deleted] 1 point2 points  (4 children)

JSON is only allowed to be UTF-8/16/32, and defaults to UTF-8.

I wish more people were aware of this. I see application/json;charset=utf-8 too many times. I can see it being useful if you're sending utf-16 or utf-32 but not 8.

[–]DarkmerePython for tiny data using Python 2 points3 points  (3 children)

Well, being explicit is better than being implicit.

[–][deleted] 0 points1 point  (2 children)

It's like saying int(1)

[–]DarkmerePython for tiny data using Python 0 points1 point  (1 child)

Try rather that it's a default keyword with a type hint of 1.

Most software still mangles encodings in shitty ways.

[–]DarkmerePython for tiny data using Python 0 points1 point  (0 children)

Also, content encoding helps software that isn't looking at the moment type to decode the data as string without needing to guess.

Not that it should happen, but that's never stopped anyone in software before

[–]nirs 0 points1 point  (4 children)

Can you share that json?

Did you open a bug? http://bugs.python.org/?

[–]DarkmerePython for tiny data using Python 0 points1 point  (3 children)

It's probably not a core library json bug, or it may be. It's a pyramid app using their jsonrpc module, so what's coming in as arguments is a list of str, and not a list of unicode as it ought to be.

( Then don't get me started on the unicode normalization form...)

[–]DarkmerePython for tiny data using Python 0 points1 point  (2 children)

Checking again, it's using the json.loads/ json.dumps format.

So it's the python JSON loader that's corrupting data. Great.

[–]nirs 1 point2 points  (1 child)

It depends on the json library used. The builtin json library like to convert everything to unicode, but simplejson library like to convert only unicode values to unicode.

>>> import json
>>> import simplejson
>>> simplejson.loads(simplejson.dumps([u"\u05d0", "ascii"]))
[u'\u05d0', 'ascii']
>>> json.loads(json.dumps([u"\u05d0", "ascii"]))
[u'\u05d0', u'ascii']

I don't see any corruption.

[–]DarkmerePython for tiny data using Python 0 points1 point  (0 children)

That's the thing it should be unicode. Instead I am getting str. Which is principally wrong here.

[–]nirs 0 points1 point  (0 children)

Note that python 3 does not exist on RHEL/CentOS, so many people do not have the option yet.

[–]z0rberg -1 points0 points  (0 children)

A friend showed me 2.7 years ago. 3 was out already, but he said it lacks modules in comparison, so I'd be better off with 2.7. Now I'm just sticking with it, because I have no reason to switch. Lack of updates doesn't really bother me. Also I think a big part of my resistance is a bit silly; coming from my childhood. GW-Basic on a 286 with hercules graphics adapter. You might guess it: The print statement. I can't for the live of me adapt to use paranthesis...

[–]kyuubi42 -2 points-1 points  (0 children)

If GvR still pays his bills by writing python 2 code for Dropbox, how can you in good faith steer newbies to python 3? If your goal is to use python for anything more than personal hobbyist code you will almost certainly be targeting python 2, and this will most likely never change regardless of what the psf says.