Skip to content

Commit

Permalink
Add coquille.print() method for coquille context (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
qexat authored May 3, 2023
1 parent 4f35fb4 commit 12c4366
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/coquille/coquille.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,26 @@ def reset(self) -> None:

apply(soft_reset, self.file)

def print(
self,
*values: object,
sep: str | None = None,
end: str | None = "\n",
) -> None:
"""
Convenient function to print in the same file as the coquille's one.
## Example
```py
>>> with Coquille.new(bold, fg_red, file=sys.stderr) as coquille:
... # same as: print("My pretty error message", file=coquille.file)
... coquille.print("My pretty error message")
```
"""

print(*values, sep=sep, end=end, file=self.file)


@dataclass(slots=True)
class Coquille:
Expand Down

0 comments on commit 12c4366

Please sign in to comment.