Four different ways to pass parameters : Function Parameters : Function : Python examples (example source code) Organized by topic

C++
PHP
Python
Python Home »  Function   » [  Function Parameters  ]  Screenshots 
 



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

           
       
Related examples in the same category
1.  Passing value or passing address Passing value or passing address
2.  Pass string value into a function Pass string value into a function
3.  Python functions are 'typeless' Python functions are 'typeless'
4.  Pass immutable and mutable value into function Pass immutable and mutable value into function
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.