I am trying to learn how to use *args and came up with this.
alist =[5,2,6,1,2]
blist =[1,5,2,4,1]
def argstest(var1, var2, *args):
print "var1", var1
print "var2", var2
temp = list(args)[0]
for i in temp:
if i > 3:
print i
argstest(5, 8, alist, blist)
>>>>> var1 5
>>>>> var2 8
>>>>> 5
>>>>>>6
>>>>>>5
>>>>>>4
Though I see how this could be very useful my first concern was that
temp = list(args)[0]
is a very odd way to convert *args
into a list, and the second was that this is not a standard way of making use of *args
.
My question what would be the standard way of converting *args
to a list?
Also, is this even the correct way to write a function that performs a task in this manner?