Steven D'Aprano added the comment:
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.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue26878>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com