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 myfunc(a,b, *args, **kwargs):
2 for ar in args:
3 print ar
4myfunc(a,b,c,d,e,f) #prints values of c,d,e,f
5
6def myfunc(a,b, *args, **kwargs):
7 c = kwargs.get('c', None) #test if 'c' defined
8 d = kwargs.get('d', None) #otherwise, return None
9 #etc
10myfunc(a,b, c='nick', d='dog', ...)
11#kwargs = dict of all the parameters that are key valued after a,b
1a = [0, 1, 2, 3, 4]
2print(*a) # print 0 1 2 3 4
3print('[' + ' '.join(map(str, a)) + ']') # print [0 1 2 3 4]
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
1def some_function (self, a, b, c, d = None, e = None, f = None, g = None, h = None):
2 #code
3