Serious question: Why would anyone still be doing anything with Python 2.7 except porting the last remnants of their code base to 3.X?
Because Python 2.7 is, IMO, a better language than Python 3+, e.g.: - I like lambda a, b: a + b syntax better than lambda a_b: a_b[0] + a_b[1] - I prefer map/reduce/filter to return lists rather than iterable - I prefer dict.keys/values/items to return sets/lists rather than iterables, unless I call dict.iter[keys/values/items]
Show HN: Python-to-Python compiler for some 3.6 features in older versions
31–40 of 113 posts
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#32Serious question: Why would anyone still be doing anything with Python 2.7 except porting the last remnants of their code base to 3.X?
Because Python 2.7 is, IMO, a better language than Python 3+, e.g.: - I like lambda a, b: a + b syntax better than lambda a_b: a_b[0] + a_b[1] - I prefer map/reduce/filter to return lists rather than iterable - I prefer dict.keys/values/items to return sets/lists rather than iterables, unless I call dict.iter[keys/values/items]
uh, `lambda a,b: a + b` works in 3.6...
> I prefer ... to return lists rather than iterable:
Why? I'm just curious. Iterables are much more flexible than lists, unless you need random access... at which point list(...) works pretty well.
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#33Serious question: Why would anyone still be doing anything with Python 2.7 except porting the last remnants of their code base to 3.X?
Because Python 2.7 is, IMO, a better language than Python 3+, e.g.: - I like lambda a, b: a + b syntax better than lambda a_b: a_b[0] + a_b[1] - I prefer map/reduce/filter to return lists rather than iterable - I prefer dict.keys/values/items to return sets/lists rather than iterables, unless I call dict.iter[keys/values/items]
It already works this way.
Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> add = lambda a, b: a + b
>>> add(1, 2)
3
> I prefer map/reduce/filter to return lists rather than iterableYou can produce a list from any iterable by passing it to `list()`. You cannot take a materialized list and make it lazy though.
> I prefer dict.keys/values/items to return sets/lists rather than iterables, unless I call dict.iter[keys/values/items]
Why? Sets are mutable. What happens when you mutate dict.values? It doesn't make sense.
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#34I'm confused with the way the "Supported features" section is divided. Does it mean I can only use f''-strings if the target version is 3.5? Why such a limitation?
That's my guess, anyway.
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#35Serious question: Why would anyone still be doing anything with Python 2.7 except porting the last remnants of their code base to 3.X?
Serious Answer: Because some of us have some rather large perfectly working systems written in 2.7 and using lots of different libraries that moving to 3 is a major project requiring a good amount of time and effort. Not all of us have hobby-sized projects on the go.
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#36Serious question: Why would anyone still be doing anything with Python 2.7 except porting the last remnants of their code base to 3.X?
I don't really see the benefit of a Python 3.6 to 2.7 transpiler/compiler though. More realistically I would require that all new code be both 2 and 3 compatible, for when the eventual migration will happen. This isn't necessarily and easy task either, but then you're only depended on the Python project, not some random transpiler that might not see further development.
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#37Serious question: Why would anyone still be doing anything with Python 2.7 except porting the last remnants of their code base to 3.X?
Because Python 3.X is not backwards compatible and we have millions of lines of production code in Python 2.X.
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#38I'm confused with the way the "Supported features" section is divided. Does it mean I can only use f''-strings if the target version is 3.5? Why such a limitation?
I think it means that you tell the compiler what version of Python the original source code is in, so it knows how to compile it. So, if your codebase has f''-strings then the compiler needs to know. That's my guess, anyway.
Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#39Re: Show HN: Python-to-Python compiler for some 3.6 features in older versions
#40Earlier quoted context omitted.
Because Python 2.7 is, IMO, a better language than Python 3+, e.g.: - I like lambda a, b: a + b syntax better than lambda a_b: a_b[0] + a_b[1] - I prefer map/reduce/filter to return lists rather than iterable - I prefer dict.keys/values/items to return sets/lists rather than iterables, unless I call dict.iter[keys/values/items]
> I like lambda a, b: a + b syntax better than lambda a_b: a_b[0] + a_b[1] It already works this way. Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> add = lambda a, b: a + b >>> add(1, 2) 3 > I prefer map/reduce/filter to return lists rather than iterable You can produce a list from any iterable by pa…