← index #8414Issue #1992
Off-topic · high · value 4.234
QUERY · ISSUE

function doesn't take keyword arguments in micropython

openby SamRoy259opened 2022-03-14updated 2023-04-30
py-core

i=10
i.to_bytes(1,byteorder='little') * 4

CANDIDATE · ISSUE

unix: "function does not take keyword arguments" message can mislead

closedby peterhinchopened 2016-04-18updated 2017-03-22

If function kw arguments are supplied from a dict, and the dict (erroneously) contains unexpected arguments, the above error message is rather misleading.

d = {'argument' : 'A', 'bar' : 0}

def foo(*, bar=False):
    print('foo')
foo(**d)

Cpython produces the self-evident

>>> foo(**d)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: foo() got an unexpected keyword argument 'argument'
>>> 

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied