A huge amount of example Python code shows the output of the Python REPL, for example:
>>> class eg(object):
... def __init__(self, name):
... self.name = name
... def hi(self):
... print "Hi %s" % (self.name)
...
>>> greeter = eg("Bob")
>>> greeter.hi()
Hi Bob
>>>
Now, the obvious thing you want to do is run the above code.. so, I run "python" and paste the above text in..
>>> >>> class eg(object):
File "<stdin>", line 1
>>> class eg(object):
^
SyntaxError: invalid syntax
>>> ... def __init__(self, name):
File "<stdin>", line 1
... def __init__(self, name):
^
The code is broken!?..
To get it to run, I would have to either..
- copy-and-paste the lines one at a time, making sure I copy all the indentation correctly. If you screw it up (say, miss a leading space, you have to start all over again)
- use a text editor to remove
>>>
and...
, then paste again
It's not a huge issue, but given how much example code is presented in this format, it seems strange you have to do this..