Member-only story
😢 Python Just Rejected Argument Shorthands
Python Steering Commitee Rejected Argument Shorthands. Passing Same Name Variables Won’t Be Easier.
While Python is quite stable there are still things that could be improved in this programming language.
Such opportunity was recognized by Joshua Bambrick and Chris Angelico. If you’re not a Python coder, it will still be interesting, I promise.
The proposal revolves around a Python syntax feature called keyword arguments. But before we dive into, let’s discuss how arguments are passed to a function. Let’s look how it’s done in Javascript:
function greet(name, age, city) {
console.log(`Hello, my nameis ${name}, I am ${age} years old, and I live in ${city}.`);
}
// Call the function with positional arguments
greet("Tom", 30, "Warsaw");
greet("Alice", 25, "Berlin");
The function accepts name, age and city. To provide values for these arguments we enumerate them separated with a comma character, and space for readability.
It’s like a standard way of passing stuff since the down of time, and it’s called positional arguments. Because the position of the argument on the list indicates what argument is what.