Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

provide a printb parameter to suppress printing a new line at the end #1930

Merged
merged 1 commit into from
Aug 15, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
provide a parameter to suppress printing a new line at the end of the…
… bytes
  • Loading branch information
Mike Day committed Aug 15, 2018
commit 31185bc059be86a7dcea155b4a06ad253a747544
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