Python Forum
variable args + named options
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
variable args + named options
#1
def foo(*varargs,bar=256):
    ...
    ...
    return bar
this is OK in Python3 but not in Python2. apparently, Python2 requires something else, like:

def foo(*varargs,**options):
    ...
    bar=256
    if 'bar' in options:
        bar=options['bar']
    ...
    return bar
how did i miss that?
Tradition is peer pressure from dead people

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


Messages In This Thread
variable args + named options - by Skaperen - Aug-15-2018, 11:14 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  command line options Skaperen 5 2,690 Aug-14-2020, 08:48 AM
Last Post: DeaD_EyE
  is there an options parser that can handle + and ++ Skaperen 1 1,590 Jul-20-2019, 07:42 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

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