Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
opts vs kwargs
#1
i've seen both used. which name is more preferred in the python community, "opts" or "kwargs"?
def show_args(*args,**kwargs):
    for arg in args:
        print(arg)
    for key,val in sorted(kwargs.items()):
        print(repr(key),'=',repr(val))
    return
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
I think kwargs is the name used by the official python documentation. It also appears as a property in the type inspect.BoundArguments for example, which 'officializes' the naming.
Reply
#3
OK. then, i'll use "kwargs" everywhere there is not a specific reason to use something else.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply
#4
I can imagine opts being used for command-line arguments so the sake of clarity between command-line and the source code. Though, I haven't seen it used. Out of curiosity, could you provide a link to a project that uses that name?
Reply
#5
i wish i could. i'm spending more of my time coding instead of studying other peoples code. i've seen so much bad code (in any language)it has turned me off.
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
  How do I instantiate a class with **kwargs? palladium 6 7,428 Feb-16-2023, 06:10 PM
Last Post: deanhystad
  kwargs question Jeff_t 8 2,988 Feb-16-2022, 04:33 PM
Last Post: Jeff_t
  Misunderstanding kwargs? Donovan 2 2,285 Aug-04-2020, 08:09 PM
Last Post: Donovan
  **kwargs question DPaul 10 4,387 Apr-01-2020, 07:52 AM
Last Post: buran
  Unpacking dictionary from .xlsx as Kwargs etjkai 5 2,865 Dec-27-2019, 05:31 PM
Last Post: etjkai
  create dictionary from **kwargs that include tuple bluefrog 2 4,889 Oct-26-2016, 10:24 PM
Last Post: Larz60+
  How do you use *args and **kwargs? Gengar 3 19,747 Sep-20-2016, 04:22 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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