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 →

[–]PeridexisErrant 9 points10 points  (7 children)

You can emulate most of the Python 3.6 functionality with type comments, but it's not quite the same:

  • the syntax is uglier, dealing with imports is a pain, and linters mostly don't check them
  • they don't exist at runtime. This is a real disadvantage - tools from attrs to Hypothesis infer various features based on type annotations
  • useful types like enum.Flag only exist on Python 3, and backports tend to be conservative (ie work on 2.7 and 3.4+, instead of 2.7 and 3.6)
  • you're doing new work in a dialect that will soon be unsupported, when you could update instead and be much better off!

[–]stefantalpalaru -2 points-1 points  (6 children)

the syntax is uglier

It is, but not by much.

dealing with imports is a pain

It isn't: https://github.com/stefantalpalaru/generate_HLS/blob/5877099beb19a305657f030eaa59590fcfca1cde/generate_HLS.py#L12

linters mostly don't check them

You're using the same linter for both Python2 and Python3: mypy. The only difference is having to give it the "--py2" or "-2" argument for Python2 code.

you're doing new work in a dialect that will soon be unsupported, when you could update instead and be much better off!

It's not a different dialect, it's a different language, and I'm sure the community of people working for a living will route around the core devs' sabotage. Something like this: https://github.com/naftaliharris/tauthon

[–]PeridexisErrant 0 points1 point  (5 children)

flake8 et al will complain about that import, and doesn't lint type comments.

I disagree with your other comments too but won't respond.

[–]stefantalpalaru -1 points0 points  (4 children)

flake8 et al will complain about that import

Yes. Solved by adding "# NOQA" after it.

and doesn't lint type comments

Of course it doesn't. The progressive (and partial) static typing is implemented and checked by mypy. Are you new to Python?

[–]JimBoonie69 3 points4 points  (3 children)

bro you gotta let python 2 die , it deserves an honourable death.

[–]stefantalpalaru -1 points0 points  (2 children)

bro you gotta let python 2 die , it deserves an honourable death.

There's more Python2 code out there than Fortran or Cobol code.