>>> import random
>>> random.SystemRandom.randint(0, 10)
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
random.SystemRandom.randint(0, 10)
TypeError: randint() missing 1 required positional argument: 'b'
SystemRandom is supposed to give random numbers though os.urandom, randint works like normal randrange:
>>> print(random.SystemRandom.randint.__doc__)
Return random integer in range [a, b], including both end points.
In IDLE a little popup suggestion appears when I type it it saying "random.SystemRandom.randint(self, a, b). I think this is the cause. I'm not very good at using classes and understanding how they work, but the first argument seems to be being passed as self, when it should be a. I never really understand why self is used when it isn't even a keyword, and how it's supposed to all just work, but it generally does.
Am I doing this wrong, or should I report this to the Python Foundation whever one is supposed to do such things?
Aucun commentaire:
Enregistrer un commentaire