Range arguments

  • Comments posted to this topic are about the item Range arguments

  • Nice question, thanks Steve
    Python basics 101...

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

  • Lol, knew answer and still selected the wrong one! Eyes, coffee! Good question thanks Steve.

    ...

  • I thought this was fun. I keep stopping to think about how it works, so good reminder for me as well.

  • nice question steve,
    thanks

    ---------------------------------------------------------------------------------------
    The more you know, the more you know that you dont know

  • <pedant>
    Based on the example, only the first argument is optional because the default increment is 1.
    </pedant>

    14090 SW TENNESSEE LN

  • 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).

  • 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.

  • radu.popa 78500 - Friday, December 14, 2018 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.

    That was my impression, as well.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • 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.

  • Steve Jones - SSC Editor - Wednesday, December 19, 2018 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.

    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.

  • 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