[Tutor] How to make def where arguments are either stated when called or entered via raw_input
David Craig
dcdavemail at gmail.com
Thu Feb 9 12:31:47 CET 2012
Hi,
I'm trying to write a function that will either take arguments when the
function is called, such as myFunc(x,y,z) or if the user does not enter
any arguments, myFunc() the raw_input function will ask for them. But I
dont know how to check how many arguments have been entered. My code is
below. Anyone know how??
Thanks
D
def NoiseCorr(file1,file2,500,0.25,0.35):
#######################################################################################
### Check number of arguments
??????????????????
#######################################################################################
### User inputs.
if numArgs == 0:
file1 = raw_input('Path to Station 1: ')
file2 = raw_input('Path to Station 2: ')
shift_length = raw_input('Length of Correlation: ')
freqMin = raw_input('Min. Frequency: ')
freqMax = raw_input('Max. Frequency: ')
More information about the Tutor
mailing list