I was expecting Python-AST wizardry and got disappointed. But not as much as by the fact that this is Python-2-style code. Otherwise it’s a thought-inspiring article that boils down to a “use a syntax tree built from nested dicts instead of writing your own DSL parser”.
Edit: technically correct is the best kind of correct
Usage of u"" and inheriting from object. Former was just added to Python 3.3+ for backwards compatibility; strs are unicode by default in Python 3 anyway. Making new-style classes doesn’t require inheriting from object in Python 3 (even in 2.7 I think) because old-style classes have been removed altogether.
Imo, code written today should not aim for Python 2 compatibility unless it’s something that has to work with a Python 2 code base that’s not migrated yet.
You’re right, technically it’s Python-3-compatible. It’s still Python-2-style code, which I think is bad because it encourages a soon-to-be-EOL’d Python version. Newly written code should just be Python-3-only.
Seems to be some kind of viewport issue on iOS / Safari- text on the left and right is clipped off:
https://imgur.com/a/kl9P6PG
I have the same issue on mobile chrome.
Fixed, it was https://github.com/TryGhost/Casper/issues/464 :)
I was expecting Python-AST wizardry and got disappointed. But not as much as by the fact that this is Python-2-style code. Otherwise it’s a thought-inspiring article that boils down to a “use a syntax tree built from nested dicts instead of writing your own DSL parser”.
Edit: technically correct is the best kind of correct
What makes you say it’s Python 2?
Usage of
u""and inheriting from object. Former was just added to Python 3.3+ for backwards compatibility; strs are unicode by default in Python 3 anyway. Making new-style classes doesn’t require inheriting from object in Python 3 (even in 2.7 I think) because old-style classes have been removed altogether.Imo, code written today should not aim for Python 2 compatibility unless it’s something that has to work with a Python 2 code base that’s not migrated yet.
Ok. I don’t think you should write “this is Python 2” when the code is (indeed) compatible with both Python 2 and 3.
You’re right, technically it’s Python-3-compatible. It’s still Python-2-style code, which I think is bad because it encourages a soon-to-be-EOL’d Python version. Newly written code should just be Python-3-only.