What's the meaning of the parameter "step=1" in pyint from Faker?

Viewed 169

I'm using the Faker Generator for Python (last version) but still trying to figure out the meaning of the paramater "step=1". Any ideas? There is nothing about this parameter in the documentation or anywhere else on the web so far.

pyint(min_value=0, max_value=9999, **step=1**)

Link to the page : Click here

Thank you much for your help!

1 Answers

pyint generates a random number effectively sampled from range(min_value, max_value+1, step). That's where the step comes in.

The documentation for pyint is severely lacking, but if we go to the source code:

def pyint(self, min_value=0, max_value=9999, step=1):
    return self.generator.random_int(min_value, max_value, step=step)

we see that it delegates to this method:

def random_int(self, min=0, max=9999, step=1):
    """Generate a random integer between two integers ``min`` and ``max`` inclusive
    while observing the provided ``step`` value.
    This method is functionally equivalent to randomly sampling an integer
    from the sequence ``range(min, max + 1, step)``.
    :sample:
    :sample size=10: min=0, max=15
    :sample size=10: min=0, max=15, step=3
    """
    return self.generator.random.randrange(min, max + 1, step)

which has a useful docstring.

Related