-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Syntax error with * in function argument list #7338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It's actually just that MicroPython doesn't support normal arguments after unpacking other arguments (bey it keyword or not), ran into this many times already,always assuming it was documented behavior :) I.e. should be mentioned in the differences but isn't, as far as I can tell. See 1e70fda |
MicroPython seems to support subsequent keyword args, but barfs on positional ones. This example is of working code: Button(writer, *self.locn(row, col), height = buttonheight, width = buttonwidth,
textcolor = BLACK, bgcolor = color,
text = text, shape = RECTANGLE,
callback = back, args = (text,)) This variant of the test case works OK: def bar():
return 1, 2
class Foo:
def __init__(self, x, y, z):
print(x, y, z)
foo = Foo(*bar(), z = 3) # Pass as a kwarg |
So tech 864B nically it documented:
But of course it would be better if it was specifically called out. 😉 |
OK, thanks both. I'd forgotten the PEP448 issue. The behaviour of |
This works as expected under CPython but throws a syntax error in MicroPython (RP2 and Unix build).
It seems that the * is interpreted as the specifier for kwonly args. Outcome:
A further observation. When I pasted this code in an
mpremote
session, a few seconds after the syntax error was reportedmpremote
fell over. Note thatmpremote
is as installed with pip3. Here is the complete session.The text was updated successfully, but these errors were encountered: