New submission from alejandro david weil <ten...@gmail.com>:

Python's documentation includes 2 source codes for alternate xrange 
implementations, which, at least in my tests, give unexpected results.

# from file:///usr/share/doc/python2.6-doc/html/library/functions.html#xrange
takewhile(lambda x:x<stop, (start+i*step for i in count()))

and:


# from: http://docs.python.org/library/functions.html?highlight=xrange#xrange
islice(count(start, step), (stop-start+step-1)//step)


I'll attach a file with source code showing that, and propose 3 different 
versions which seems to work fine. (I've prefer the first one, but python lacks 
of sign() function).

----------
assignee: docs@python
components: Documentation
files: test_xrange.py
messages: 135159
nosy: docs@python, tenuki
priority: normal
severity: normal
status: open
title: documentation: alternate version of xrange seems to fail.
versions: Python 2.6, Python 2.7
Added file: http://bugs.python.org/file21887/test_xrange.py

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue12003>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to