Skip to content

Commit

Permalink
provide a parameter to suppress printing a new line at the end of the…
Browse files Browse the repository at this point in the history
… bytes (#1930)

provide a parameter to suppress printing a new line at the end of the bytes.
existing behavior is not changed.
  • Loading branch information
Mike Day authored and yonghong-song committed Aug 15, 2018
1 parent ecfbc74 commit 49d475f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/python/bcc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def detect_language(candidates, pid):

FILESYSTEMENCODING = sys.getfilesystemencoding()

def printb(s, file=sys.stdout):
def printb(s, file=sys.stdout, nl=1):
"""
printb(s)
Expand All @@ -54,7 +54,8 @@ def printb(s, file=sys.stdout):
buf = file.buffer if hasattr(file, "buffer") else file

buf.write(s)
buf.write(b"\n")
if nl:
buf.write(b"\n")
file.flush()

class ArgString(object):
Expand Down

0 comments on commit 49d475f

Please sign in to comment.