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 ...
随机推荐
- bzoj2163
题解: 拆点网络流 然后用总和-最大流 代码: #include<iostream> #include<cstring> #include<cstdio> #inc ...
- 在JavaScript中进行文件处理,第三部分:处理事件和错误
译注:原文是<JavaScript高级程序设计>的作者Nicholas Zakas写的,本翻译纯属为自己学习而做,仅供参考.原文链接:这里 FileReader对象用来读取浏览器可以访问的 ...
- 2018.11.29 Wireless technology roadmap(1)
1物联网还是卖开发板阶段. BT NBIoT 窄带物联网(Narrow Band Internet of Things) Sigfox Zigbee Wifi:大数据量传输 LoRA :远距离无线电( ...
- Ubuntu上交叉编译valgrind for Android 4.0.4的过程与注意事项
编译环境:Ubuntu x86_64(Linux root 2.6.32-45-generic #101-Ubuntu SMP Mon Dec 3 15:39:38 UTC 2012 x86_64 G ...
- 在myeclipse中配置DB Driver(数据库用MySql),并在myeclipse执行sql语句操作
在myeclipse中配置DB Driver(数据库用MySql),并在myeclipse执行sql语句操作 MyEclipse6.5 , mysq驱动jar包为mysql-connector ...
- keras_基本网络层结构(2)_卷积层
参考文献:http://keras-cn.readthedocs.io/en/latest/layers/convolutional_layer/ 卷积层 Conv1D层 keras.layers.c ...
- Win7系统Visual Studio 2013配置OpenCV3.1图文详解
Win7系统Visual Studio 2013配置OpenCV3.1图文详解 OpenCV3.1对硬件加速和移动开发的支持相对于老版本都有了较大改进,支持新的开发工具,更易于扩展,配置方式也比以前简 ...
- iOS-----MFMessageCompose 和 MFMailComposeViewController的使用方法
MFMessageCompose 和 MFMailComposeViewController的使用方法 使用MFMessageComposeViewCOntroller发短信 应用想自己提供界面让用户 ...
- POJ 2236:Wireless Network(并查集)
Wireless Network Time Limit: 10000MS Memory Limit: 65536K Total Submissions: 36363 Accepted: 150 ...
- flask第二十六篇——模板【控制语句】【2】
如果你也在学flask,就请加船长的公众号:自动化测试实战 我们先补充一下for循环的知识,我们之前说过,flask是由Jinja2+sqlAlchemy+werkzeug组成的,我们现在学的控制语句 ...