I want to write simple lambda or function that takes a string, changes to lowercase except for the first case and copies the result to clipboard in Linux.
I have lambda:
to_lower = lambda s : s[0].upper() + s[1:].lower()
This is ok:
to_lower("some Sentence with Incorrect Size of characterS")
Some sentence with incorrect size of characters
But how I copy the result of this lambda to clipboard automatically, so that I can paste it into a text editor. At the moment, I have to manually select text in python command line to copy to clipboard.
Check out pyperclip: http://coffeeghost.net/2010/10/09/pyperclip-a-cross-platform-clipboard-module-for-python/
import pyperclip
pyperclip.copy('The text to be copied to the clipboard.')