This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author steven.daprano
Recipients DqASe, steven.daprano
Date 2016-04-29.11:12:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20160429111143.GW13497@ando.pearwood.info>
In-reply-to <1461924586.32.0.0506461504844.issue26878@psf.upfronthosting.co.za>
Content
On Fri, Apr 29, 2016 at 10:09:46AM +0000, DqASe wrote:
> Added file: http://bugs.python.org/file42649/x.py

Ah, I see! That makes sense now. Thanks.

Why don't you just set the initial state of the lists in the doctests? 
That makes much better documentation. Imagine a more complex example 
where the function name means nothing to you and the topic is 
unfamiliar:

    >>> piyo(mylist, hogera=12, fuga=7)
    >>> mylist
    [0, 2, 4, 6, 14, 16]

But if I show the initial state of the list, not only is the meaning 
more obvious (which makes it better documentation and a better test), 
but your problem goes away:

    >>> mylist = [0, 2, 4, 6, 8, 10, 12, 14, 16]
    >>> piyo(mylist, hogera=12, fuga=7)
    >>> mylist
    [0, 2, 4, 6, 14, 16]

I fear that this suggested feature will encourage poor doctests that 
rely on global state rather than local state.
History
Date User Action Args
2016-04-29 11:12:06steven.dapranosetrecipients: + steven.daprano, DqASe
2016-04-29 11:12:06steven.dapranolinkissue26878 messages
2016-04-29 11:12:05steven.dapranocreate