Skip to content
This repository was archived by the owner on Oct 5, 2020. It is now read-only.

lovely printer#3

Merged
jb3 merged 3 commits into
python-discord:masterfrom
spyoungtech:master
Jun 19, 2020
Merged

lovely printer#3
jb3 merged 3 commits into
python-discord:masterfrom
spyoungtech:master

Conversation

@spyoungtech
Copy link
Copy Markdown
Contributor

@spyoungtech spyoungtech commented Feb 7, 2019

Love is in the air. Is it in your Python, too?

TODO:

  • make a __main__ that accepts input from stdin
  • fill character for whitespace?
  • golf it
  • setup.py

From the README:

Lovely Printer

The idea here is simple: You have a program that prints things. Now you can have a program that prints things in the shape of a heart!

Usage

The main usage is via context manager that temporarily overrides the builtin print.
That is, you should be able to use this with any existing program that uses print! How lovely!

Suppose you have your normal boring program

# my_program.py
def main():
    print('This is just an example')

Make it lovely like so

from lovely_printer import lovely_print
from my_program import main

with lovely_print():
    main()
# then print returns to normal
print("Isn't that lovely?")

Then you should see the output something like

 This    is 
j    u s    t
      a     n
           e
  x       a
   m     p
    l   e
     T h
      i

Isn't that lovely?

@lemonsaurus
Copy link
Copy Markdown
Contributor

I love this one so much.

@skrungly
Copy link
Copy Markdown
Contributor

skrungly commented Feb 7, 2019

oh cool! i'm interested to see what else could be done with this idea, actually. the code is beautiful too. if you want, you can make a separate file in the PR where all of the code is made weird and esoteric (to fit with the rest of the repo :D)

@spyoungtech
Copy link
Copy Markdown
Contributor Author

spyoungtech commented Feb 7, 2019

Yeah, I was thinking of a one-liner implementation that uses a class for the context manager. Something like

lovely_printer = type('',(),dict(__enter__=lambda s:s, __exit__=lambda s:s))()

(inspired by David Beazley's flail)

Should be doable, and very diabolical. Not sure if I'll have time to get around to it, but also happy to accept contributions :P

@spyoungtech spyoungtech changed the title lovely printer [wip] lovely printer Feb 7, 2019
@spyoungtech spyoungtech changed the title [wip] lovely printer lovely printer Apr 11, 2019
@spyoungtech
Copy link
Copy Markdown
Contributor Author

probably won't get around to changes I want. Feel free to just merge

@jb3 jb3 merged commit b3b1f2e into python-discord:master Jun 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants