Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6912455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:05:40+00:00 2026-05-27T09:05:40+00:00

Today, I was just told about the seed() function from a programmer much more

  • 0

Today, I was just told about the seed() function from a programmer much more experienced than me. I normally just call choice() with a list as an argument, as I don’t need anymore random number functionality than that.

My programmer friend told me that calling seed is necessary because otherwise Python always begins random number operations with zero as the default seed. This means that although the numbers appear random, we are really getting the same sequence every time.

This strikes me as rather odd. Does the choice() function, for example, really not call seed before it does its thing? Or is the reason it can’t programmatically change its seed because that in of itself would involve picking a random number, and obviously that it is a bit of a problem if our end goal is also to pick a random number!

I’m ranting a bit here, but I’m wondering if anyone has a clear idea of how all this was implemented.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T09:05:41+00:00Added an answer on May 27, 2026 at 9:05 am

    Your friend is dead wrong, and would know so if he read the documentation for the seed() function:

    Initialize the basic random number generator. Optional argument x can be any hashable object. If x is omitted or None, current system time is used; current system time is also used to initialize the generator when the module is first imported. If randomness sources are provided by the operating system, they are used instead of the system time (see the os.urandom() function for details on availability).

    (Emphasis mine.)

    He’s guessing based on his knowledge of how it works in other languages. The seed() function is mainly provided so that you can get a reproducible stream of pseudorandom numbers (which is necessary for some specific applications).

    The functions you call directly from the random module are actually aliases to methods of a hidden instance of the random.Random class. Each instance, at least in effect, calls seed() within its __init__().

    The choice() function obviously does not call seed() before operation, because that would mean re-seeding before every choice, which defeats the purpose of seeding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Today somebody told me that interface implementation in C# is just Can-Do relationship, not
I've just today learned of asp.net mvc, and I'm wondering what is needed from
So today I just came across the 'live()' function that binds any future and
I just started thinking about creating/customizing a web crawler today, and know very little
I've read about binary searches on Wikipedia for the first time today and just
today I just ran rake db:migrate... well, two things happened, first it reversed from
Just today I've started using Drupal for a site I'm designing/developing. For my own
I just started reading Effective C++ today and got to the point where the
I just started playing around with threading today and I ran into something that
Im just starting with localization today and need some information. I have a project

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.