Skip to main content

Minitest is inspired by Ruby minispec.

Project description

This project write some useful functions related to print:

p, pp, pl, ppl,
p_format, pp_format, pl_format, ppl_format.

github: https://github.com/jichen3000/py_print_helper

pypi: https://pypi.python.org/pypi/print_helper


Author

Colin Ji jichen3000@gmail.com

How to install

pip install print_helper

How to use

p, pp, pl, ppl, p_format, pp_format, pl_format, ppl_format these functions could been used by any object.

p, print with title. This function will print variable name as the title. code:

import print_helper

value = "Minitest"
value.p()

value.p("It is a value:")

value.p(auto_get_title=False)

print result:

value : 'Minitest'

It is a value: 'Minitest'

'Minitest'

pp, pretty print with title. This function will print variable name as the title in the first line, then pretty print the content of variable below the title. code:

import print_helper

value = "Minitest"
value.pp()

value.pp("It is a value:")

value.pp(auto_get_title=False)

print result:

value :
'Minitest'

 It is a value:
'Minitest'

'Minitest'

pl, print with title and code loction. This function just like pt, but will print the code location at the first line. And some editors support to go to the line of that file, such as Sublime2. code:

import print_helper

value = "Minitest"
value.pl()

value.pl("It is a value:")

value.pl(auto_get_title=False)

print result:

    File "/Users/Colin/work/minitest/test.py", line 76
value : 'Minitest'


    File "/Users/Colin/work/minitest/test.py", line 77
 It is a value: 'Minitest'


    File "/Users/Colin/work/minitest/test.py", line 78
'Minitest'

ppl, pretty print with title and code loction. This function just like ppt, but will print the code location at the first line. Notice: it will print a null line firstly. code:

import print_helper

value = "Minitest"
value.ppl()

value.ppl("It is a value:")

value.ppl(auto_get_title=False)

print result:

    File "/Users/Colin/work/minitest/test.py", line 76
value :
'Minitest'


    File "/Users/Colin/work/minitest/test.py", line 77
 It is a value:
'Minitest'


    File "/Users/Colin/work/minitest/test.py", line 78
'Minitest'

p_format, get the string just like p function prints. I use it in debugging with log, like: logging.debug(value.p_format()) code:

import print_helper

value = "Minitest"
value.p_format()

return result:

value : 'Minitest'

pp_format, get the string just like pp function prints. I use it in debugging with log, like: logging.debug(value.pp_format()) code:

import print_helper

value = "Minitest"
value.pp_format()

return result:

value :\n'Minitest'

pl_format, get the string just like pl function prints. I use it in debugging with log, like: logging.debug(value.pl_format()) code:

import print_helper

value = "Minitest"
value.pl_format()

return result:

line info: File "/Users/Colin/work/minitest/test.py", line 76, in <module>\nvalue : 'Minitest'

ppl_format, get the string just like ppl function prints. I use it in debugging with log, like: logging.debug(value.ppl_format()) code:

import print_helper

value = "Minitest"
value.ppl_format()

return result:

line info: File "/Users/Colin/work/minitest/test.py", line 76, in <module>\nvalue :\n'Minitest'

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

print_helper-1.0.1.tar.gz (3.6 kB view details)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page