Python Forum
AssertionError when trying the sys module in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
AssertionError when trying the sys module in python
#8
(Nov-20-2022, 07:04 PM)Gribouillis Wrote:
(Nov-20-2022, 05:19 PM)BliepMonster Wrote: I already found a solution, so I won't use 'Rich' or anything else.
Can you share your solution to print with colors in the IDLE IDE?

The solution to printing text:
import sys
color = sys.stdout.shell
color.write('Anything you want', 'STRING')
color.write('can go here\n', 'STRING')
color.write('Just remember to end the line with the \\n', 'STRING')
Output:
Anything you want can go here Just remember to end the line with the \n
(In the string color)
Now, this doesn't work for variables. For that, you can just use print() with end=' ' to keep it on the same line. It isn't as good as color, but it works.
import sys
color = sys.stdout.shell
color.write('This', 'STRING')
print('Is on the same line', end = ' ')
color.write('As this', 'STRING')
Gribouillis likes this post
The only stupid person in the world, is the person that doesn't ask questions.
-Someone smart
Reply


Messages In This Thread
RE: AssertionError when trying the sys module in python - by BliepMonster - Nov-21-2022, 12:24 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  AssertionError: View function mapping is overwriting an existing endpoint function Zhavi221 7 19,190 Apr-17-2019, 01:07 PM
Last Post: Zhavi221

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020