Ask HN: What should be added to the syntax of Python and why?
7 comments
Ditch the general purpose variable annotations thing and make strong typing types first class
Curly braces, to make whitespace insignificant. I don't like significant whitespace.
I don't know the name of this idiom, but the following is valid Python:
import pandas as pd
my_df = (
I also use plotly like so:
my_plot = (
Not exactly function chaining, but I guess it has a similar effect.
I'm happy with Python's syntax nowadays and much prefer seeing improvements on library / environment related things.
import pandas as pd
my_df = (
pd.Dataframe(<fetch_data>)
.join(<...>)
.query(<...>)
.sort_values(<...>)
)I also use plotly like so:
my_plot = (
px.line(<...>)
.update_xaxes(<...>)
.update_layout(<...)
)Not exactly function chaining, but I guess it has a similar effect.
I'm happy with Python's syntax nowadays and much prefer seeing improvements on library / environment related things.
It's called a fluent interface.
I want braces.
I would love separate variable initialization vs assignment. I know that ship has sailed.
It's interesting, I never cared about that until I did "Crafting Interpreters" and realized how separating those two actions helps clarify scopes.
Being realistic I know it's too large of a breaking change and will never land in the language but I can dream right?
It's interesting, I never cared about that until I did "Crafting Interpreters" and realized how separating those two actions helps clarify scopes.
Being realistic I know it's too large of a breaking change and will never land in the language but I can dream right?
None propagation. It such a pain to constantly check for None when accessing very deep nested structures (as I had to do often with JSON data).
There is a PEP for this[1] but it is currently deferred.
[1]: https://peps.python.org/pep-0505/
There is a PEP for this[1] but it is currently deferred.
[1]: https://peps.python.org/pep-0505/
Multi-line lambda. It would be more easier to use than cramming a piece of code into a single line.
I know in Lisp languages you can extend the syntax easily, but I was wondering if there are any needs for that in Python.
[0] https://pypi.org/project/pipe/