fprint

hhpy.main.fprint(*args, file: str = '_fprint.txt', sep: str = ' ', mode: str = 'replace', append_sep: str = '\n', timestamp: bool = True, do_print: bool = False, do_tprint: bool = False)[source]

Write the output of print to a file instead. Supports also writing to console.

Parameters:
  • args – the arguments to print
  • file – the name of the file to print to
  • sep – separator
  • mode – weather to append or replace the contents of the file
  • append_sep – if mode==’append’, use this separator
  • timestamp – weather to include a timestamp in the print statement
  • do_print – weather to also print to console
  • do_tprint – weather to also print to console using tprint
Returns:

None

Examples

The below output gets written to a file called ‘fprint.txt’

>>> fprint('Hello World', file='fprint.txt')

The below output gets written both to a file and to console

>>> fprint('Hello World', file='fprint.txt', do_print=True)
'Hello World'