Skip to content

Commit

Permalink
Printer: Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sils committed Mar 19, 2015
1 parent a4c2f2d commit 6ed620c
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions coalib/output/printers/Printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ class Printer:
"""
A Printer is an object that can output (usually unformatted) text.
This object is the base class of every printer and handles output concatenation to support the usual delimiter/end
parameters. If you want to implement a Printer you want to override the _print method which takes just one string
which is ready to be outputted.
This object is the base class of every printer and handles output
concatenation to support the usual delimiter/end parameters. If you want to
implement a Printer you want to override the _print method which takes just
one string which is ready to be outputted.
Examples for some printers are:
- ConsolePrinter for console and file output
Expand All @@ -13,16 +14,28 @@ class Printer:
"""

def _print(self, output, **kwargs):
"""
Prints the output parameter. (Will be invoked via the print() method
while it supports the *args, delimiter and end signature.)
:param output: A string which shall be printed. (Everything is in it so
you don't want to append a newline.)
:param kwargs: Arbitrary additional keyword arguments which can be used
to configure arbitrary things specifically to the
printer.
"""
raise NotImplementedError

def print(self, *args, delimiter=' ', end='\n', **kwargs):
"""
Prints the given arguments to an output medium.
:param args: Will be outputted.
:param args: Will be outputted.
:param delimiter: Delimits the args.
:param end: Will be appended in the end (without an additional delimiter)
:param kwargs: Will be passed through to the Printer derivative handling the actual printing
:param end: Will be appended in the end (without an additional
delimiter)
:param kwargs: Will be passed through to the Printer derivative
handling the actual printing
"""
output = str(delimiter).join(str(arg) for arg in args) + str(end)

Expand Down

1 comment on commit 6ed620c

@Udayan12167
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack.

Please sign in to comment.