Cut and paste

You may often want to reuse code developed within the shell without having to type it again. At other times, you may find sample code, perhaps from an online tutorial, and you'd like to apply it to a Python shell. PyCrust provides a couple of simple cutting and pasting options, listed in table 4.2.

Table 4.2 Keyboard shortcuts related to cutting and pasting in the PyCrust shell

Key Combination



Copy selected text, removing prompts


Copy selected text, retaining prompts


Cut selected text


Paste from clipboard


Paste and run multiple commands from clipboard

Another feature of pasting is that PyCrust recognizes and automatically strips out the standard Python prompts from any code that is pasted into the PyCrust shell. This makes it easy to copy example code from a tutorial or email message, paste it into PyCrust, and try it without having to do manual cleanup.

At times, when you copy code you may want to remove the PyCrust prompts, such as when copying the code into your source files. Other times you'll want to retain the prompts, such as when you are copying examples into a document, or posting to a newsgroup. PyCrust provides both options when copying text from the shell.

Was this article helpful?

0 0

Post a comment