If the poster has copied from the user interface, especially in interactive languages such as Python lines entered by the user will start with either
... while lines of responses and error messages will not.
Wouldn't it be possible for a copy mechanism to only copy lines that started with the prompt and skip any lines that didn't plus strip the known prompt characters out of the copied code?
This would greatly simplify copying code from questions & answers to try the code out and work on the solution.
Obviously such changes should only be applied when copying from examples/answers rather than when copying into them.
For example, if the user posts:
Python 2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> print 2, 2 >>> print fred Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'fred' is not defined >>> print fred() Traceback (most recent call last): File "<stdin>", line 1, in <module> NameError: name 'fred' is not defined >>> def fred(): ... return (27) ... >>> print fred() 27 >>>
And I select and paste it I would like it to paste as:
print 2, print fred print fred() def fred(): return (27) print fred()