Bugs item #1119418, was opened at 2005-02-09 11:57
Message generated for change (Settings changed) made by rhettinger
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1119418&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
>Priority: 6
Submitted By: Martin Blais (blais)
Assigned to: Nobody/Anonymous (nobody)
Summary: xrange() builtin accepts keyword arg silently
Initial Comment:
Calling ``xrange(10, 100, step=10)`` results in a
xrange(10, 100) iterator silently. In contrast,
``range(10, 100, step=10)`` raises an exception. See
test program below.
Two possible fixes:
1. fix xrange() so that it returns a xrange(10, 100,
10) iterator
2. make sure that xrange() raises an exception too.
#!/usr/bin/env python
def foo( min_, max_, step=1 ):
print min_, max_, step
print '===================='
foo(10, 100, 10)
foo(10, 100, step=10)
print '===================='
print xrange(10, 100, 10)
print xrange(10, 100, step=10)
print '===================='
print range(10, 100, 10)
print range(10, 100, step=10)
elbow:/usr/.../lib/python2.4$ /tmp/a.py
====================
10 100 10
10 100 10
====================
xrange(10, 100, 10)
xrange(10, 100)
====================
[10, 20, 30, 40, 50, 60, 70, 80, 90]
Traceback (most recent call last):
File "/tmp/a.py", line 16, in ?
print range(10, 100, step=10)
TypeError: range() takes no keyword arguments
> /tmp/a.py(16)?()
-> print range(10, 100, step=10)
(Pdb)
elbow:/usr/.../lib/python2.4$
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1119418&group_id=5470
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com