Clarification on deprecation warning for seeding

datetime.time(s) returns a time object. The only types supported by random.seed are the ones listed in the error message. The error message is telling you that you shouldn’t pass objects of unsupported types to random.seed, but rather pass something else.

I don’t know what s is in your program, or why you’re trying to seed the RNG like this.
Given that the datetime.time constructor looks like this

datetime.time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None, *, fold=0)

I believe there are only 24 possible values that you could be passing to random.seed here, which is almost certainly not what you wanted to do.

If you want to use the current time as a seed for the random number generator, use

random.seed(time.time())

instead.

1 Like