Python Forum
is there a way: repeat key word args
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
is there a way: repeat key word args
#1
i would like to allow the same key word argument to be repeated as many times as desired with different values, just as i can do on command arguments. if this is not possible the i will have to just live with accepting a list or set (or tuple or frozenset).
    x = explore(1,place='usa',place='eu')
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#2
To me that doesnt make sense as the function would not know which to assign place variable as.

Im assuming you know you can pass a list via
args = ['usa','eu']
def explore(*args):
    pass
Recommended Tutorials:
Reply
#3
i did mention that i would have to accept a list. i was hoping for such an object. i did create such a thing in C. and it even retained insert order.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 1,256 May-22-2023, 10:39 PM
Last Post: ICanIBB
Question How to compare two parameters in a function that has *args? Milan 4 1,182 Mar-26-2023, 07:43 PM
Last Post: Milan
  Repeat request by else stsxbel 2 1,149 Jul-30-2022, 03:34 PM
Last Post: stsxbel
  get out of while loop and stop repeat Frankduc 11 2,866 Apr-26-2022, 10:09 PM
Last Post: deanhystad
  Avoid multiple repeat in indent Frankduc 8 2,789 Jan-18-2022, 05:46 PM
Last Post: Frankduc
Question Problem: Check if a list contains a word and then continue with the next word Mangono 2 2,455 Aug-12-2021, 04:25 PM
Last Post: palladium
  *args implementation and clarification about tuple status amjass12 10 3,913 Jul-07-2021, 10:29 AM
Last Post: amjass12
  [SOLVED] Good way to handle input args? Winfried 2 2,003 May-18-2021, 07:33 PM
Last Post: Winfried
  Two Questions, *args and //= beginner721 8 3,421 Feb-01-2021, 09:11 AM
Last Post: buran
  How to discard list repeat values akanowhere 7 3,572 Dec-28-2020, 09:14 PM
Last Post: akanowhere

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020