Unpacking Argument Lists,unpackingargument,#The reverse
Unpacking Argument Lists,unpackingargument,#The reverse
#The reverse situation occurs when the arguments are already in a list or tuple #but need to be unpacked for a function call requiring separate positional #arguments. For instance, the built-in range() function expects separate start #and stop arguments. If they are not available separately, write the function #call with the *-operator to unpack the arguments out of a list or tuple:print range(3, 6) # normal call with separate argumentsargs = [3, 6]print range(*args) # call with arguments unpacked from a list
- Open a file and read char by char,openchar,file = open
- Compare integers using if structures, relational operato
- Using the and-or Trick Safely,and-ortrick,a = '' b = '
- print rounds off digits,roundsdigits,a = 3
- Create Python codecs from Unicode mapping files,codecs
- Mixed-type conversions,mixed-type,a = 3
热门文章:
相关内容
- Open a file and read char by char,openchar,file = open(
- Compare integers using if structures, relational operators and equali
- Using the and-or Trick Safely,and-ortrick,a = '' b = '
- print rounds off digits,roundsdigits,a = 3
- Create Python codecs from Unicode mapping files,codecsmapping,'''PY
- Mixed-type conversions,mixed-type,a = 3
- Key action: Return key,keyactionreturn,from Tkinter
- String escape sequences Demo,escapesequences,print '\a'pr
- Unit test for apihelper.py,unitapihelper.py,'''Unit test
- keyword arguments,arguments,def birthday
评论关闭