How to make scientific notation the default in the Python interpreter?

Click For Summary
SUMMARY

The discussion centers on configuring the Python interpreter to display numbers in scientific notation by default. Users express frustration with the standard numeric output format and explore alternatives, including creating a custom REPL loop for enhanced output control. A resource is provided for writing an interactive REPL in Python, which allows for tailored number formatting. Modifying the interpreter's code is also suggested as a potential solution.

PREREQUISITES
  • Familiarity with Python programming language
  • Understanding of REPL (Read-Eval-Print Loop) concepts
  • Basic knowledge of modifying Python scripts
  • Experience with number formatting in Python
NEXT STEPS
  • Research how to create a custom REPL loop in Python
  • Explore Python's built-in number formatting options
  • Learn about modifying Python's source code for custom behavior
  • Investigate third-party libraries for enhanced number formatting
USEFUL FOR

Python developers, educators, and data scientists looking to customize numeric output in the Python interpreter for improved readability and presentation.

andresordonez
Messages
65
Reaction score
0
Hi, I'm tired of reading numbers like 695500000, and using %e all the time is not a practical solution.

Thanks.
 
Technology news on Phys.org
The Python "interactive mode" is just a REPL loop. You can write your own REPL loop in python pretty easily, and then you will have full control over how output is printed.

http://blog.hackthology.com/writing-an-interactive-repl-in-python
 
Last edited by a moderator:
Thanks, though I thought it could be easier than that. I guess I could modify somehow some code of the interpreter.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
2K
Replies
3
Views
2K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 25 ·
Replies
25
Views
6K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
Replies
55
Views
7K