prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.19k stars 277 forks source link

[question] How to make ptpython output like python? #543

Open Freed-Wu opened 1 year ago

Freed-Wu commented 1 year ago

ptpython only output when it exit:

$ ptpython
In [1]: from ctypes import CDLL
In [2]: libc = CDLL('libc.so.6')
In [3]: libc.printf(b"hello")
5
In [4]: # press <C-D> to exit
hello

For python

$ python
Python 3.10.12 (main, Jun  6 2023, 22:43:10) [GCC 12.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ctypes import CDLL
>>> libc = CDLL('libc.so.6')
>>> libc.printf(b'hello')
5
hello>>>

Why they are different? How to make them same? TIA!

Freed-Wu commented 11 months ago

As a completion, this problem only happens on printf(), not puts().