December 11, 2018 at 9:50 pm
Comments posted to this topic are about the item Range arguments
December 11, 2018 at 9:50 pm
Nice question, thanks Steve
Python basics 101...
____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
December 11, 2018 at 11:34 pm
Lol, knew answer and still selected the wrong one! Eyes, coffee! Good question thanks Steve.
...
December 12, 2018 at 2:15 am
I thought this was fun. I keep stopping to think about how it works, so good reminder for me as well.
December 12, 2018 at 5:14 am
nice question steve,
thanks
---------------------------------------------------------------------------------------
The more you know, the more you know that you dont know
December 12, 2018 at 11:27 am
<pedant>
Based on the example, only the first argument is optional because the default increment is 1.
</pedant>
14090 SW TENNESSEE LN
December 12, 2018 at 11:26 pm
There is no correct answer possible!
You have no chance to give only the second argument to any function without giving the first one.
There are two forms of function prototype:
- one of them is with one argument only;
- the other is with three arguments (the last one has default value defined ➡ that is the only one that is optional).
December 14, 2018 at 9:26 am
So, if the 1st arg is optional, how does one call this function to pass the 2nd and 3rd args?
To me, only the 3rd arg is truly optional. This seems to be confirmed by the function signature definition on the link provided in the question:
range(start, stop[, step])
I can see how Python allows passing just one arg and infer that refers to stop.
Nevertheless, the 1st arg (start) seems "semi-optional" at best.
December 16, 2018 at 10:08 am
radu.popa 78500 - Friday, December 14, 2018 9:26 AMSo, if the 1st arg is optional, how does one call this function to pass the 2nd and 3rd args?To me, only the 3rd arg is truly optional. This seems to be confirmed by the function signature definition on the link provided in the question:
range(start, stop[, step])I can see how Python allows passing just one arg and infer that refers to stop.
Nevertheless, the 1st arg (start) seems "semi-optional" at best.
That was my impression, as well.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 19, 2018 at 1:49 pm
The first argument is optional in that if you pass in one argument, it is for the second parameter. If you pass two, then the first is the first parameter and the second is the second parameter. If you pass three, they are used in their positions.
I think this is strange, but the first argument is optional.
December 20, 2018 at 12:20 am
Steve Jones - SSC Editor - Wednesday, December 19, 2018 1:49 PMThe first argument is optional in that if you pass in one argument, it is for the second parameter. If you pass two, then the first is the first parameter and the second is the second parameter. If you pass three, they are used in their positions.I think this is strange, but the first argument is optional.
If the first argument were optional function declaration would look like:
range
([start, ]stop[, step])
but there are two distinct function declarations (see answer Ref:) with the same name and totally different scope of arguments (commonly used in C/C++, ...):
range
(stop)range
(start, stop[, step])
It might be misinterpreted as a single function with first argument optional.
December 20, 2018 at 1:49 pm
Yes, an overloaded function with two implementations.
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply