Four different ways to pass parameters : Function Parameters : Function PYTHON examples


PYTHON examples » Function » Function Parameters »

 

Four different ways to pass parameters


Four different ways to pass parameters


def echo(*args, **kwargs): print args, kwargs

print echo(12, a=3, b=4)



pargs = (12)
kargs = {'a':3'b':4}
print apply(echo, pargs, kargs)



print apply(echo, args)              # traditional: tuple

print func(*args)                    new apply-like syntax

print echo(*pargs, **kargs)          # keyword dictionaries too

print echo(0, *pargs, **kargs)       # normal, *tuple, **dictionary

           
       



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON examples

 Navioo Function
» Function Parameters