def my_func(a = 1, b = 2, c = 3):
print(a + b + c)
my_func()
#OUTPUT = 6
my_func(2)
#This changes the value of a to 2
#OUTPUT = 7
my_func(c = 2)
#This changes the value of c to 2
#OUTPUT = 5
def myfunc(a,b, *args, **kwargs):
for ar in args:
print ar
myfunc(a,b,c,d,e,f) #prints values of c,d,e,f
def myfunc(a,b, *args, **kwargs):
c = kwargs.get('c', None) #test if 'c' defined
d = kwargs.get('d', None) #otherwise, return None
#etc
myfunc(a,b, c='nick', d='dog', ...)
#kwargs = dict of all the parameters that are key valued after a,b
#set the variable = to None, and then write over none if there the argument
#is used.
async def joke(ctx, args=None):
if args == None:
await ctx.send('you :D')
else:
await ctx.send('%s is the true joke' % args)