pwtools.common.frepr

pwtools.common.frepr(var, ffmt='%.16e')[source]

Similar to Python’s repr(), but return floats formated with ffmt if var is a float.

If var is a string, e.g. ‘lala’, it returns ‘lala’ not “‘lala’” as Python’s repr() does.

Parameters:
  • var (almost anything (str, None, int, float))

  • ffmt (format specifier for float values)

Examples

>>> frepr(1)
'1'
>>> frepr(1.0)
'1.000000000000000e+00'
>>> frepr(None)
'None'
>>> # Python's repr() does: 'abc' -> "'abc'"
>>> frepr('abc')
'abc'