[Zope3-dev] Re: [Zope-Checkins] CVS: Zope3/src/persistent/tests- test_persistent.py:1.5 persistent.txt:1.2

Tres Seaver tseaver at zope.com
Thu Mar 11 10:52:03 EST 2004


Tim Peters wrote:
> [Jeremy Hylton]
> 
>>>In emacs, execute the command py-shell.  You'll get a Python
>>>interpreter prompt.  You can cut-and-paste code from the interpreter
>>>shell into a doctest.
> 
> 
> [Chris Withers]
> 
>>Can I do that with multi-line doctest examples, or do the '...'s
>>fubar everything?
> 
> 
> Chris, doctest has been a standard core Python module since 2.1, and was in
> wide use before than (that's why it got folded into the core).  So read the
> docs, or just look at a doctest.  In the standard Python test suite,
> test_generators.py is a good long example.


Chris is asking whether the Python interpreter will choke when cutting 
and pasting an entire multi-line doctest example.  E.g., try cutting and 
pasting the following text into your Python interpreter session::

--------------- 8< --------------------------------
 >>> class Foo:
...     def __init__(self, bar):
...         self._bar = bar
...     def bar(self):
...         return self._bar
...
 >>> foo = Foo('baz')
 >>> foo.bar()
baz
--------------- 8< --------------------------------

$ python
Python 2.2.2 (#1, Feb 24 2003, 19:13:11)
[GCC 3.2.2 20030222 (Red Hat Linux 3.2.2-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> >>> class Foo:
   File "<stdin>", line 1
     >>> class Foo:
      ^
SyntaxError: invalid syntax
..... # all the rest are horked, too.


Tres.
-- 
===============================================================
Tres Seaver                                tseaver at zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com




More information about the Zope3-dev mailing list