Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
zero or one argument
#2
Not that i am aware of
>>> def func(*arg):
...     print(arg)
... 
>>> func()
()
>>> func('test')
('test',)
>>> func('test', 2)
('test', 2)
but i guess if you want to restrict more than 2 arguments you can just assert the length of arg to 2 or less
Recommended Tutorials:
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