Pyperclip

Today I finished listening to the most recent episode of Talk Python to Me, #327 Little Automation Tools in Python. The episode was dedicated to the small tools that people create that both help get a (small) job done. These are often the tasks that get people into something larger, although it's not necessary. Most of the praise and attention goes to the people who develop the big software that many people use—and for good reason—but for the rest of us who are just getting by, the smaller projects are more real.

One package that was mentioned toward the end is an insanely simple package that does something that I've been looking for. Several of the scripts I write are command line tools that return some text that I then copy out of the terminal window and paste somewhere else. This package, Pyperclip, puts the output right into the clipboard. That only saves a few seconds each time, I suppose, but it's annoying to have to do that little bit of copypasting when I know that there's got to be a better way.

import pyperclip
pyperclip.copy('Hello, world!')

... and then paste it wherever.

Leave a Reply

Your email address will not be published.