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 8854491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:53:34+00:00 2026-06-14T13:53:34+00:00

I have a function which returns a list of tuples, that I would like

  • 0

I have a function which returns a list of tuples, that I would like to iterate through:

def get_parameter_product(num_parameters, lower_range, upper_range):
    param_lists = [ xrange(lower_range, upper_range) for _ in xrange(num_parameters)]   
    return list(itertools.product(*param_lists))

for p in get_parameter_product(3, 0, 5):
    print p,

(0, 0, 0), (0, 0, 1), (0, 0, 2), (0, 0, 3), (0, 0, 4), ... , (4, 4, 2), (4, 4, 3), (4, 4, 4)

However, for larger values of num_parameters is take a lot of memory to allocate. Is it possible to convert this to a generator?

  • 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-06-14T13:53:35+00:00Added an answer on June 14, 2026 at 1:53 pm

    itertools.product is already a generator. You can just return it instead of converting it to a list.

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

Sidebar

Related Questions

Suppose I have a function like this: def getNeighbors(vertex) which returns a list of
I have a function, readnorm which returns a list of related data from a
I have a function which returns 3 numbers, e.g.: def numbers(): return 1,2,3 usually
I have an SQL function which returns a list of Teams. I want to
I have a function which returns a list of property values from a collection:
I have a method (or function) which returns a reference to a list of
I have a function client_groups in a model that returns a list of Group
I would like to have a function which get start_day and end_day as two
I have a remote function testdwr, which returns a list of objects(test). How should
I would like to write a function GetHashCodeOfList() which returns a hash-code of a

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.