Skip to content

Make your output sparkle, without long repetitive code

License

Notifications You must be signed in to change notification settings

Zwork101/Dazzle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dazzle ✨

Make your output sparkle, without long repetitive code

Who doesn't love color, I know I do. However I don't like any color libs, they can take up so much column space, and can end up being repetitive, leading to functions such as

def announcement(title: str, desc: str):
    print(colorlib.BLUE + "Announcement: " + title + colorlib.WHITE + "\n\n" + desc)

I actually have nothing against these functions, but they got me thinking. If I'm always going to end up making functions, let's cut to the chase.

from dazzle import Fore, INP

announce = Fore.BLUE + "Announcement: " + INP + Fore.WHITE + "\n\n" + INP
announce("Hello World", "Fizz Buzz")

Each of these methods would result in the same thing. Another issue with color libs, is that they can be a pain to implement later down the road. Dazzle has you covered here too.

with Back.BLUE + INP + " " + Fore.RED + " " + INP:
    print("John:", "Howdy Mary")
    print("Mary:", "Howdy John")

Dazzle will override the print function, so that it will add the colors provided in the with statement. Keep in mind that any excess input will be ignored.

Pitfalls

When you call a color chain, you pass write=False in so that it doesn't print the result. If write is True, it won't output anything. If False it will output that string.

Don't

  • Start it with a normal string, use t(<string>) if you need to do that.
  • Use with statement with inconsistent print functions.
  • Wrap it with (). It should still work, but their's no need.
  • Use repr when requiring an input.
  • Be stupid.

These were the docs, this is a very small and simple library. here you'll find a list of colors that are available. Dazzle covers Fore, Back, Style and Cursor, all as you'd expect. Thanks for using dazzle! ✨

About

Make your output sparkle, without long repetitive code

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages