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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:52:03+00:00 2026-06-09T15:52:03+00:00

I am writing a little script in which I call itertools.product like so: for

  • 0

I am writing a little script in which I call itertools.product like so:

for p in  product(list1,list2,list3):
            self.createFile(p)

Is there a way for me to call this function without knowing in advance how many lists to include?

Thanks

  • 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-09T15:52:04+00:00Added an answer on June 9, 2026 at 3:52 pm

    You can use the star or splat operator (it has a few names): for p in product(*lists) where lists is a tuple or list of things you want to pass.

    def func(a,b):
        print (a,b)
    
    args=(1,2)
    func(*args)
    

    You can do a similar thing when defining a function to allow it to accept a variable number of arguments:

    def func2(*args): #unpacking
       print(args)  #args is a tuple
    
    func2(1,2)  #prints (1, 2)
    

    And of course, you can combine the splat operator with the variable number of arguments:

    args = (1,2,3)
    func2(*args) #prints (1, 2, 3)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a little commercial PHP Script which would be a VPN (PPTP)
I'm a complete newb writing out a small little script in which the third
Recently I was writing a little CLI script which needed to repeatedly read dates
I amm writing a little python script that will grab information from VMs of
I'm writing a little Python extension in C/C++, and I've got a function like
I'm writing a Python script which connects to remote hosts over a (super complicated)
I know very, very little of javascript, but I'm interested in writing a script
I'm getting a little frustrated on a little PowerShell script I'm writing. Basically I
I'm essentially writing a little script that needs to save several different files as
I am writing a little python script to learn VIM basics (I'm a beginner

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.