My current code is similar to the following.
def func(args):
optionalparameters = ((args.split(':')[1]).split(' '))[1:]
second_func(optionalparameters)
This assumes args
is a colon-separated string; it takes the second half, splits it into space-delimited words and returns (a list of?) all but the first. The situation where more than one colon is included isn't yet handled, because I am new to the language.
Can the optional_parameters be passed not as a list? Since parameters are optional will the following be effective?
def func(args):
optionalparameters = ((args.split(':')[1]).split(' '))[1:]
val1=val2=val3=None
try:
val1 = optionalparameters[0]
except IndexError:
pass
try:
val2 = optionalparameters[1]
except IndexError:
pass
try:
val3 = optionalparameters[2]
except IndexError:
pass
second_func(val1, val2, val3)
It seems likely that standard library modules might be able to do much of this. Any help in argument handling is highly appreciated.