3 ms·
I go back and forth on Python in this regard, specifically the named vs positional arguments in that an argument can be one or the other. Part of me prefers ju
by cletus 5y ago
I go back and forth on Python in this regard, specifically the named vs positional arguments in that an argument can be one or the other.
Part of me prefers just using an anonymous object in Javascript. Typescript is also cleaner than that.
Day to day I use Hack (FB's PHP fork), which has a type system and shapes, which are essentially anonymous objects in the JS/TS sense but a little more awkward syntactically:
function foo(shape(
'a' => int,
'b' => int,
?'c' => int,
)): void;
foo(shape('a' => 1, 'b' => 2));
But with Python you sort of have this awkward mix of args and kwargs.
- klibertp 5y agoYou can mark args as keyword only or positional only in the recent versions of Python (starting 3.7, maybe?)