Can someone explain what the method seed does from module random in the following example? Thanks in advance.
random.seed(42) #same connections each time for easier debugging
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The random function is pseudo random, not real random. It produces seemingly random values from a seeded value, normally the seeded value is set by the system clock or some other changing value that would make more sense, but if the random function is seeded by the same static value (42 in this case) the output from the random function will be exactly the same on each program execution and thus predictable, which can be good for debugging code.