Skip to content

"Side effect" of demo code #389

@aamrun

Description

@aamrun

I came across your project while browsing the packages installed on my system ( Ubuntu 22.04 running as WSL on Windows 11). I ran the demo code below which is mentioned both on your PyPi and Github homepages :

from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background')
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

Doing so, I got the output below :

image

As can be seen, not only the line with the text containing 'green background' but the two following lines also have a green background. It's interesting that the 'green background' line is green only for the sentence but the two subsequent lines are green for the entire screen width.

I don't know if this is the intended effect but it looked like a bug to me and I came up with this 'fix' :

from colorama import Fore, Back, Style
print(Fore.RED + 'some red text')
print(Back.GREEN + 'and with a green background' + Back.RESET)
print(Style.DIM + 'and in dim text')
print(Style.RESET_ALL)
print('back to normal now')

Now the output looks like this :

image

Also, because a Fore.RESET hasn't been applied on the first line, the 'green background' text is in red and the 'dim text' is really dim, especially on a black background. With this line :

print(Fore.RED + 'some red text' + Fore.RESET)

The output looks more 'proper'

image

Again, not sure if the current code is intended to work "as it is" or if this 'issue' has been reported in the past. I came across it and thought of letting you know.

Thanks !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions