4 ms·
Python does not do this: > help(int) class int(object) | int([x]) -> integer | int(x, base=10) -> integer > list(map(int, ["1", "2
by etra0 3y ago
Python does not do this:
> help(int)
class int(object)
| int([x]) -> integer
| int(x, base=10) -> integer
> list(map(int, ["1", "2", "3"]))
[1, 2, 3]
Even if you define a function that takes two parameters, it complains about not having a second one:
>>> def to_int(a, b):
... return int(a, base=b)
...
>>> list(map(to_int, ["1", "2", "3"]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: to_int() missing 1 required positional argument: 'b'
- qayxc 3y agoNow replace def to_int(a, b): ... with the JS semantic equivalent of def to_int(*args): ... because that's how JS function declarations work. You simply have the option to assign names to positional parameters, i.e. function fn(a, b) { comnsole.log(a, b) } is just syntactic sugar for function fn() { const a = arguments[0] const b = arguments[1] console.log(a, b) } and that's what people seem to struggle with and argument over for whatever strange reason.