Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
zero or one argument
#3
ok, then i'm stuck with variable arguments.  i was wanting to do something like:
def myfun(myarg=None):
    if myarg is None:
        myarg='default'
    ...

myfun() # zero arguments OK
...
myfun('a string') # one argument OK
...
myfun('a string','an extra string') # two arguments so it should fail here
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
zero or one argument - by Skaperen - Oct-14-2017, 12:55 AM
RE: zero or one argument - by metulburr - Oct-14-2017, 01:14 AM
RE: zero or one argument - by Skaperen - Oct-14-2017, 01:55 AM
RE: zero or one argument - by metulburr - Oct-14-2017, 02:45 AM
RE: zero or one argument - by wavic - Oct-14-2017, 08:22 AM
RE: zero or one argument - by gruntfutuk - Oct-14-2017, 11:59 AM
RE: zero or one argument - by buran - Oct-14-2017, 12:28 PM
RE: zero or one argument - by snippsat - Oct-14-2017, 12:44 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  SyntaxError: positional argument follows keyword argument syd_jat 3 6,008 Mar-03-2020, 08:34 AM
Last Post: buran

Forum Jump:

User Panel Messages

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