kyle k
kyle k

Reputation: 5512

How to run code contained in clipboard

How can i directly run the contents of the clipboard, I tried using the command python pbpaste but it said python: can't open file 'pbpaste': [Errno 2] No such file or directory does the code have to be contained in a file to run it?

Upvotes: 0

Views: 387

Answers (1)

Matteo Italia
Matteo Italia

Reputation: 126827

Since pbpaste produces its output on the standard output and Python can take its input from the standard input, you can simply pipe them:

pbpaste | python

Upvotes: 3

Related Questions