You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like this idea, for it is a common use case to just style lines of text (and not bleed the effects to the rest of the output). The extension of functionality to add a call behavior is simple enough, but it's also very opinionated.
In the
AnsiCodes
, we use some logic in the__init__
to makeFore.RED
for example to a string.We could subclass the
str
class to make it callable, for example:Then in the
code_to_chars
method, we can wrap the string into aFormattingString
:This makes it useful for short formatting, like:
which will print the
foo
into red, and then reset it, so:Is this an improvement that might be considered?
The text was updated successfully, but these errors were encountered: