Tag Archives: Python


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.

Unnecessary code, finance class edition

Ever since classes went fully online in the spring semester, I've had a horrible time concentrating during lectures. There's the usual self-caused distractions—the phone, the browser, literally any other room of the house besides the one with the lecture playing—but even when I'm there, trying to focus like a Good Boy, it's really hard to lock in and take something from the class. Since the classes are three hours long, only twice a week, it's a real grind trying to force focus. Don't look to me for advice on how to do it.

Except today—I tried something accidentally. In the finance class we were doing some calculations on bond values, and I went to Excel like I normally would for calculations. And we occasionally needed to shift the term length on the bonds, and calculate the annual value like we would on a timeline, and Excel was just feeling a little too stiff—changing the number of rows or columns or whatever on the fly, manually. And I was focusing that great anyway, so I popped open Eclipse and started trying to create the calculations in Python instead.


I never really got the thing to do much yet (finance_sandbox.py) but there was a different kind of focus that set it once I started doing it. Setting up classes and thinking about what attributes of the bonds I had to capture from the lecture, trying to quickly think of abstractions so that I could calculate problems with different features from the lecture—having to create and re-create the most basic aspects of the things we were learning about turned out to be very helpful.