Live data from Hacker News

New features you can't use unless you are in Python 3

asmeurer.com

151–160 of 264 posts

Re: New features you can't use unless you are in Python 3

#152
post #62

Just wondering but what should you do if you decide to go with Python 3 and find a library you want to use that isn't compatible and you are short on time?

At this point in time, if you want to use a library and it isn't compatible with py3, then you probably shouldn't use that library. Essentially all actively maintained libraries are converted, and we are even starting to see libs that do not support py2.

As a counterexample, there's ROS (Robot Operating System, which is not an OS actually but a middleware plus a lot of libraries), and it still doesn't support Py3 officially. There is some support in fact, but you probably don't want to have even more potential problems with ROS for not that big of a benefit.

Re: New features you can't use unless you are in Python 3

#153

Earlier quoted context omitted.

Overloading operators for cute purposes is usually a misfeature. There was a fad for this in the early C++ days. I once wrote a marshalling library which overloaded "||", so that you could write p = stream || rec.a || rec.b || rec.c; and get an object which, if written, marshalled the record, and if read, unmarshalled it. The marshalling order was only specified once. Cute, but in retrospect, bad. Python's classic ov…

> It seems to be best to restrict the math operators to math. Ken Iverson would probably disagree.

I've coded in APL. There's a reason it died out. Although it was the first language with "do this on all that stuff" operators.

Re: New features you can't use unless you are in Python 3

#154
post #134

Earlier quoted context omitted.

Nice, do they have similar for base64 too?

import base64

Yeah, I know about that, but that's still longer and more annoying than the old way. Maybe I should just make my own library that just modifies strings and byte arrays and adds a few things for the common binary operations I do.

Re: New features you can't use unless you are in Python 3

#155
post #54

Earlier quoted context omitted.

What do you mean, default ? "/usr/bin/python" symlinked to "/usr/bin/python3" instead of "/usr/bin/python2"?

Installed by default.

As the GP said, Python3 is installed by default on any big distro for 5-10 years already.

It's not the default because /bin/python is synlinked to python2. You have to explicitly run it.

Re: New features you can't use unless you are in Python 3

#156

Earlier quoted context omitted.

> It seems to be best to restrict the math operators to math. Ken Iverson would probably disagree.

I've coded in APL. There's a reason it died out. Although it was the first language with "do this on all that stuff" operators.

> I've coded in APL. There's a reason it died out.

Judging from its surviving successors (J particularly), the reason is “keyboards” not “operator overloading”.

Re: New features you can't use unless you are in Python 3

#157
post #66

I did not know you could append to a Path via "/", but that's really awesome! I also really love working with generators when I write Python. They are just such a simple idea that's very powerful and I miss them so much when I go back to javascript (I know javascript has them now, but I haven't written them, and they don't look as fluent as Python 3, where the large parts of the language design is based around them).

Overloading operators for cute purposes is usually a misfeature. There was a fad for this in the early C++ days. I once wrote a marshalling library which overloaded "||", so that you could write p = stream || rec.a || rec.b || rec.c; and get an object which, if written, marshalled the record, and if read, unmarshalled it. The marshalling order was only specified once. Cute, but in retrospect, bad. Python's classic ov…

About the parenthesis, Haskell got "". It's ugly as hell, but it's ugly in a way that is easy to get used to.

Re: New features you can't use unless you are in Python 3

#158
post #66

I did not know you could append to a Path via "/", but that's really awesome! I also really love working with generators when I write Python. They are just such a simple idea that's very powerful and I miss them so much when I go back to javascript (I know javascript has them now, but I haven't written them, and they don't look as fluent as Python 3, where the large parts of the language design is based around them).

Overloading operators for cute purposes is usually a misfeature. There was a fad for this in the early C++ days. I once wrote a marshalling library which overloaded "||", so that you could write p = stream || rec.a || rec.b || rec.c; and get an object which, if written, marshalled the record, and if read, unmarshalled it. The marshalling order was only specified once. Cute, but in retrospect, bad. Python's classic ov…

> Overloading operators for cute purposes is usually a misfeature

Every single time I see printing to an IO stream in C++ I think 'why are they bit-shifting that... oh right'.

Re: New features you can't use unless you are in Python 3

#159

Earlier quoted context omitted.

Consistency and keyword args are useful.

"11. There should be one-- and preferably only one --obvious way to do it." from the Zen of Python. Somebody intentionally misread it as, "There should be only one way to do it." They obviously made a grave mistake. Same with many 2->3 changes.

The old way was foolishly inconsistent with the rest of the language. It only serves as an small expedient in the REPL.

Re: New features you can't use unless you are in Python 3

#160

Earlier quoted context omitted.

Compare these instead: for i in range(n): yield i yield from range(n)

Both seem quite readable, really. Seems similar to the usual "list comprehensions vs. for loop" arguments; to which I always think "use whichever is readable for the given code".

The thing about "list comprehensions vs. loop" is that you can compose comprehensions, but you must edit loops to change them.

I fail to see how anything similar would apply here.

Post reply on HN