Receiving Arguments via Pointers in Python -
Receiving Arguments via Pointers in Python -
i have class function defined this. intention send multiple arguments .
for testing ,i called :class_name("argument1","argument2") , says , _init_accepts atmost 1 arguments , 3 given
def __init__(self, **options): name in options: self.__dict__[name] = options[name]
what proper way handle ?
any suggestions welcome......
you want utilize 1 asterisk instead of two. double asterisks named arguments. there nice explanation in python documentation if interested in reading further.
def __init__(self, *options): name in options: self.__dict__[name] = name
however, code think real issue calling function incorrectly.
you want phone call like:
class_name(argument1="some value") def __init__(self, **options): name,val in options.iteritems(): self.__dict__[name] = val
python arguments
Comments
Post a Comment