1def myfunc(a,b, *args, **kwargs):
2 c = kwargs.get('c', None)
3 d = kwargs.get('d', None)
4 #etc
5myfunc(a,b, c='nick', d='dog', ...)
1def my_func(a = 1, b = 2, c = 3):
2 print(a + b + c)
3
4my_func()
5#OUTPUT = 6
6
7my_func(2)
8#This changes the value of a to 2
9#OUTPUT = 7
10
11my_func(c = 2)
12#This changes the value of c to 2
13#OUTPUT = 5
1def myfunc(a,b, *args, **kwargs):
2 for ar in args:
3 print ar
4myfunc(a,b,c,d,e,f)
5
1def some_function (self, a, b, c, d = None, e = None, f = None, g = None, h = None):
2 #code
1#set the variable = to None, and then write over none if there the argument
2#is used.
3async def joke(ctx, args=None):
4 if args == None:
5 await ctx.send('you :D')
6 else:
7 await ctx.send('%s is the true joke' % args)
1def myfunc(a,b, *args, **kwargs):
2 c = kwargs.get('c', None)
3 d = kwargs.get('d', None)
4 #etc
5myfunc(a,b, c='nick', d='dog', ...)
6