You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't noticed a strong convention in the Python community for "making print flexible enough to meet user needs". There's the extendable custom string formatting, but that looks like it may be a deep rabbit hole.
If it was me, my approach would be maximise flexibility for users by minimising work done here:
Have a single function that provides all possible "thing to string" conversion functionality
Make something like NumPy's set_printoptions() to support changing the default string representation globally / in contexts using with (optional)
Drop all support for sending the strings to files, and let users handle that through more generic Python methods available
With the flexibility of maybe swapping out 1 with custom string formatting if you feel the need in the future.
Activity
jhavl commentedon Oct 27, 2021
Thanks for noticing that, the docs seem to be out of date on Github pages. I'll get those rebuilt with the next pip release
petercorke commentedon Nov 2, 2021
I've changed this stuff a lot, used to be all done by printline. Are these the right primitives?
btalb commentedon Nov 11, 2021
I haven't noticed a strong convention in the Python community for "making print flexible enough to meet user needs". There's the extendable custom string formatting, but that looks like it may be a deep rabbit hole.
If it was me, my approach would be maximise flexibility for users by minimising work done here:
set_printoptions()to support changing the default string representation globally / in contexts usingwith(optional)With the flexibility of maybe swapping out 1 with custom string formatting if you feel the need in the future.
petercorke commentedon Jul 27, 2026
Checkout PR #200 which separates printing from stringifying.