Unpacking Argument Lists
[Unpacking Argument Lists]
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:

In the same fashion, dictionaries can deliver keyword arguments with the **-operator:

参考:http://docs.python.org/2.7/tutorial/controlflow.html#unpacking-argument-lists
Unpacking Argument Lists的更多相关文章
- Python Tutorial 学习(五)--Data Structures
5. Data Structures 这一章来说说Python的数据结构 5.1. More on Lists 之前的文字里面简单的介绍了一些基本的东西,其中就涉及到了list的一点点的使用.当然,它 ...
- 笔记-python-tutorial-4.controlflow( and function)
笔记-python-tutorial-4.controlflow( and function) 1. 函数 1.1. 定义函数 def name(x): “””函数的第一行语句可以是可 ...
- [译]The Python Tutorial#5. Data Structures
[译]The Python Tutorial#Data Structures 5.1 Data Structures 本章节详细介绍之前介绍过的一些内容,并且也会介绍一些新的内容. 5.1 More ...
- [译]The Python Tutorial#4. More Control Flow Tools
[译]The Python Tutorial#More Control Flow Tools 除了刚才介绍的while语句之外,Python也从其他语言借鉴了其他流程控制语句,并做了相应改变. 4.1 ...
- 【译】Python数据结构
本章将更详细地描述您已经学到的一些内容,并添加了一些新的内容. 5.1 关于列表的更多内容 列表数据类型有一些更多的方法. 以下是列表对象的所有方法: list.append(x) 将项目添加到列表的 ...
- net programming guid
Beej's Guide to Network Programming Using Internet Sockets Brian "Beej Jorgensen" Hallbeej ...
- 像职业选手样编码:地道Python
Code Like a Pythonista: Idiomatic Python David Goodger goodger@python.org http://python.net/~goodger ...
- variadic function 的使用
最近在看<the c programming language> K&R 7.3章 Variable-length Argument Lists 变长参数列表, 笔记一下用法 1 ...
- How to use *args and **kwargs in Python
Or, How to use variable length argument lists in Python. The special syntax, *args and **kwargs in f ...
随机推荐
- ipvsadm命令介绍
为了更好的让大家理解这份命令手册,将手册里面用到的几个术语先简单的介绍一下: 1,virtual-service-address:是指虚拟服务器的ip 地址 2,real-service-addres ...
- instancetype 与id
1 .依照cocoa的命名规则,alloc,init这类方法,如果以id为返回类型,会返回类本身的类型,但类方法的返回类型,LLVM(clang)编译器无法判断,也就是说如果 用id作为返 ...
- 解决Jenkins权限配置错误,导致登录时出现没有Overall/read权限
问题 由于初次接触jenkins,于是在搭建好jenkins以后,想要对用户进行管理,于是乎开始在系统管理->configure Global Security里设置用户的权限. 在启用安全-& ...
- 网络编程I/O函数介绍
read和write #include <unistd.h> ssize_t read(int fd, void *buf, size_t count); ssize_t write(in ...
- 报错:Syntax error on tokens, delete these tokens
该问题意思是说:你有两个双引号或者你有没有关闭%>符号. 仔细检查代码 出现这样的错误一般是括号.中英文字符.中英文标点.代码前面的空格,尤其是复制粘贴的代码,去掉即可.
- 5.4完成其他模块的xadmin后台注册
courses adminx.py from .models import Course, Lesson, Video, CourseResource import xadmin class Cou ...
- BZOJ4886: [Lydsy1705月赛]叠塔游戏(环套树森林&贪心)
4886: [Lydsy1705月赛]叠塔游戏 Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 198 Solved: 76[Submit][Stat ...
- springboot整合mybatis增删改查(一):项目创建
新建 打开 IDEA 工具,通过 File -> New -> Project->Spring Initializr 主要步骤包括: 选择 Spring Initializr 项目 ...
- proc 文件系统学习
proc.txt翻译 ------------------------------------------------------------------------------Version 1.3 ...
- C#中XML文档注释编译DLL引用到其它项目
引用地址:http://zhidao.baidu.com/link?url=jSGYEBysE4gBExtNsHCVk3vd2OK2cMlaf02cS79GdRuGueTBdFJB0btOdBYkg_ ...