ATLAS Offline Software
|
Print functions emulating python2 softspace rules. More...
Go to the source code of this file.
Namespaces | |
python.fprint | |
Functions | |
def | python.fprint._formatFloat (x) |
def | python.fprint._formatFloats (l) |
def | python.fprint.fprint (f, *args) |
def | python.fprint.fprintln (f, *args) |
def | python.fprint.fwrite (f, *args) |
Variables | |
python.fprint.c | |
Print functions emulating python2 softspace rules.
print >>f, 'a', print >>f, 'b'
would insert a space between ‘a’ and ‘b’, while
print >>f, 'a', print >>f, '\nb'
would not put a space after the ‘a’.
This was implemented by an ‘internal’ attribute of file objects called ‘softspace’. If non-zero, then the next print should emit a space at the start.
This functionality is not present in the python 3 print function.
In the case where one has existing python 2 output formatting where one wants to preserve the spacing and have it work consistently in both py2 and py3, the functions here may be used. Use fprint to print a string with no terminating newline, and use fprintln to print a string with a terminating newline. Calls to f.write() should be replaced with fwrite().
In addition to spacing, py2 and py3 format floating-point numbers differently. These functions try to produce py2-default foramtting.
Definition in file fprint.py.