No , no, but you can do it .
JavaScript implementation in Python range()
Trying to emulate how this works in Python , I would create a function like this:
function range(start, stop, step) { if (typeof stop == 'undefined') {
See this jsfiddle for proof.
Comparing range() in JavaScript and Python
It works as follows:
range(4) returns [0, 1, 2, 3] ,range(3,6) returns [3, 4, 5] ,range(0,10,2) returns [0, 2, 4, 6, 8] ,range(10,0,-1) returns [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] ,range(8,2,-2) returns [8, 6, 4] ,range(8,2) returns [] ,range(8,2,2) returns [] ,range(1,5,-1) returns [] ,range(1,5,-2) returns [] ,
and its Python python works the exact same way (at least in the indicated cases):
>>> range(4) [0, 1, 2, 3] >>> range(3,6) [3, 4, 5] >>> range(0,10,2) [0, 2, 4, 6, 8] >>> range(10,0,-1) [10, 9, 8, 7, 6, 5, 4, 3, 2, 1] >>> range(8,2,-2) [8, 6, 4] >>> range(8,2) [] >>> range(8,2,2) [] >>> range(1,5,-1) [] >>> range(1,5,-2) []
So, if you need a function to work similarly to Python range() , you can use the above solution.