2

This question might generate be a very simple answer of, "Yep, that's fine". I'm trying to come up with a simple way to generate a random number from between (inclusive)

1 and 9223372036854775807

Should be easy right? I'm doing this and I think it's working correctly.

import random
print (random.randint(1,9223372036854775807))

My concern is that 9223372036854775807 is the upper bound of BIGINT for the SQL datatype. Does randint have an upper bound like the SQL datatype? Is there some other pythonic way I should be approaching this?

1
  • 2
    randint() works with long integers, so you should be fine. Commented Jun 26, 2018 at 14:03

1 Answer 1

1

According to docs.python.org , randint returns a random integer N such that a <= N <= b. Alias for randrange(a, b+1). There's nothing about limits.

Also, in Python 3 the plain int type is unbounded.

So, I think it should be fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.