Live data from Hacker News

Migrating to Python 3 with pleasure

github.com

141–150 of 181 posts

Re: Migrating to Python 3 with pleasure

#141
post #122
post #109

Earlier quoted context omitted.

Every time somebody mentions how awsome f-strings are makes me laugh. It was around ten years ago when Python community was looking down at Perl and shell with their string interpolation, but now that Python got pretty much the same it's suddenly not considered a misfeature.

Have you considered that maybe the language had not evolved enough for them to be appealing. With b'' and u'' string syntax coming into the language, there is a realisation that string interpolation can be an opt-in feature among other reasons. What you have is decision making analogous to the function evaluate(string_interpolation, python_ecosystem) which is different from evaluate(string_interpolation)

> With b'' and u'' string syntax coming into the language, there is a realisation that string interpolation can be an opt-in feature among other reasons.

This argument won't fly. Did you know that string interpolation in Perl and shell was always an opt-in feature? And despite that it was frowned upon by Python community.

Re: Migrating to Python 3 with pleasure

#142
post #120
post #42

Earlier quoted context omitted.

It's twice as slow, doesn't work with more than one dictionary, you can't easily control the merge prescience and you can't (easily) use expressions/variables in the keys: {**x, 'fo'+'o': 'bar', **y}

return dict(x, **{'fo'+'o': 'bar'}, **y) The new syntax is some mild syntactic sugar. (Which isn't a bad thing IMO)

And people say perl is unreadable ;)

Re: Migrating to Python 3 with pleasure

#143
post #136

Earlier quoted context omitted.

I distribute python programs. Macs only have Python 2 by default.

But surely that's not stopping anyone. As someone above said, just use pyenv to run Python 2.7x and Python 3. It's not as if anyone has to settle for using only legacy Python.

At the moment my instructions are "grab this script and run 'python script.py'". That is ok for about everyone.

I don't want to have to start teaching pyenv to every academic or student I want to send a script to.

Re: Migrating to Python 3 with pleasure

#144
post #120
post #42

Earlier quoted context omitted.

It's twice as slow, doesn't work with more than one dictionary, you can't easily control the merge prescience and you can't (easily) use expressions/variables in the keys: {**x, 'fo'+'o': 'bar', **y}

return dict(x, **{'fo'+'o': 'bar'}, **y) The new syntax is some mild syntactic sugar. (Which isn't a bad thing IMO)

This is the most unreadable code I've seen so far.

Just skip all this and use Perl instead. You can write far more idiomatic, succinct readable code in Perl than you can in Python.

The whole point of Python is to not write code this way.

Re: Migrating to Python 3 with pleasure

#145
post #81
post #63

I'd been a 2.7 holdout for ages, but when f-strings were greenlit for 3.6, I decided then and there that all my new personal projects would be written in 3. I'm glad I did. F-strings are wonderful, as is pathlib and the enhanced unpacking syntax. Since I started my current job, I've also been writing as many scripts as I can in Python 3 as well (and Docker has been a godsend for that because I can now deploy 3.6 scri…

Could you provide more info on your setup for this? I work on some EL 6 servers and would be interested in using this setup.

If Python 3.4 is good enough, you can get it from the EPEL repos.

Re: Migrating to Python 3 with pleasure

#146
post #9

Earlier quoted context omitted.

Dicts never had an iteration order, though. If you relied on dicts iterating in order, you were kind of asking for it.

I believe newer Python versions have at least deterministic iteration order (correct me if I'm wrong), while some previous ones had a non-deterministic one (non-deterministic between mutiple invocations of the interpreter). But there is also OrderedDict which iterates in assignment order.

Python dicts have always been touted as an unordered data structure though, so yeah, if you're depending on any type of order you shouldn't be.

Re: Migrating to Python 3 with pleasure

#147
post #137
post #69

Earlier quoted context omitted.

Isn't python 3 usually installed alongside python/pip 2.7 as python3/pip3, and everything kept seperately?

If you use pyenv, it is.

Even if you don't, any OS-level package manager should easily install Python3 alongside whatever the base install is without any conflicts as `python3` and pip as `pip3`.

Homebrew, apt, pacman, etc. all have one-line python3 installation.

Re: Migrating to Python 3 with pleasure

#149
post #144
post #120

Earlier quoted context omitted.

return dict(x, **{'fo'+'o': 'bar'}, **y) The new syntax is some mild syntactic sugar. (Which isn't a bad thing IMO)

This is the most unreadable code I've seen so far. Just skip all this and use Perl instead. You can write far more idiomatic, succinct readable code in Perl than you can in Python. The whole point of Python is to not write code this way.

This is what I have been saying for a long time. Readability in Python is an illusion.

Re: Migrating to Python 3 with pleasure

#150
post #130

Earlier quoted context omitted.

And the multiprocessing and threading pools. And collections.ChainMap. And f-strings. And yield from. And type hints. And statistics. And ipadress. And secrets. And matmul. And subprocess.run. Come on, Python 3 is packed with awesomeness !

multiprocessing and threading pools While certainly awesome, these are in python 2.7 as well. Although I don't remember if they where in 2.7 first of back-ported to 2.7 from 3.

__Reliable__ pools are only in 3.
Post reply on HN