-1

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.

M. A. Kishawy
  • 5,001
  • 11
  • 47
  • 72
  • there is [`word.title()` method](https://docs.python.org/3/library/stdtypes.html#str.title) – jfs Sep 10 '15 at 21:34

1 Answers1

3

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.')
CodeViking
  • 236
  • 3
  • 6