← index #7950Issue #456
Related · high · value 0.067
QUERY · ISSUE

`flush` keyword argument for `print()`?

openby will-caopened 2021-10-29updated 2025-10-03
enhancementpy-core

CPython 3.3+ supports a flush keyword argument.

https://docs.python.org/3/library/functions.html#print

$ micropython
MicroPython 4fe0332-dirty on 2021-10-27; linux version
Use Ctrl-D to exit, Ctrl-E for paste mode
>>> print(5, flush=True)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: extra keyword arguments given
CANDIDATE · ISSUE

Problem with kwargs

closedby lurchopened 2014-04-09updated 2014-04-13
bugenhancement

Consider this simple function:

def testfun(arg1=1,arg2=2):
    print(arg1,arg2)

In micropython when I call it as testfun(arg2='two') I get the error TypeError: function missing required positional argument #-1 whereas in CPython3.3 it prints 1 two as expected.

In CPython3.3 if I do testfun(arg3='three') I get TypeError: testfun() got an unexpected keyword argument 'arg3' whereas micropython tells me TypeError: function does not take keyword arguments - right class, misleading message ;-)

def testfun2(arg1,arg2=2):
    print(arg1,arg2)

CPy responds to a call of testfun2() with TypeError: testfun2() missing 1 required positional argument: 'arg1' whereas uPy says TypeError: function takes 2 positional arguments but 0 were given - again right class, (possibly) misleading message.

Let me know if you'd prefer me to break these out into separate issues rather than lumping them together.

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