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的更多相关文章

  1. Python Tutorial 学习(五)--Data Structures

    5. Data Structures 这一章来说说Python的数据结构 5.1. More on Lists 之前的文字里面简单的介绍了一些基本的东西,其中就涉及到了list的一点点的使用.当然,它 ...

  2. 笔记-python-tutorial-4.controlflow( and function)

    笔记-python-tutorial-4.controlflow( and function) 1.      函数 1.1.    定义函数 def name(x): “””函数的第一行语句可以是可 ...

  3. [译]The Python Tutorial#5. Data Structures

    [译]The Python Tutorial#Data Structures 5.1 Data Structures 本章节详细介绍之前介绍过的一些内容,并且也会介绍一些新的内容. 5.1 More ...

  4. [译]The Python Tutorial#4. More Control Flow Tools

    [译]The Python Tutorial#More Control Flow Tools 除了刚才介绍的while语句之外,Python也从其他语言借鉴了其他流程控制语句,并做了相应改变. 4.1 ...

  5. 【译】Python数据结构

    本章将更详细地描述您已经学到的一些内容,并添加了一些新的内容. 5.1 关于列表的更多内容 列表数据类型有一些更多的方法. 以下是列表对象的所有方法: list.append(x) 将项目添加到列表的 ...

  6. net programming guid

    Beej's Guide to Network Programming Using Internet Sockets Brian "Beej Jorgensen" Hallbeej ...

  7. 像职业选手样编码:地道Python

    Code Like a Pythonista: Idiomatic Python David Goodger goodger@python.org http://python.net/~goodger ...

  8. variadic function 的使用

    最近在看<the c programming language> K&R 7.3章 Variable-length Argument Lists  变长参数列表, 笔记一下用法 1 ...

  9. 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 ...

随机推荐

  1. Backbone设计思路和关键源码分析

    一. Backbone的江湖地位: backbone作为一个老牌js框架为大规模前端开发提供了新的开发思路:前端MVC模式,这个模式也是前端开发演变过程中的一个重要里程碑,也为MVVM和Redux等开 ...

  2. Alpha阶段第1周 Scrum立会报告+燃尽图 02

    作业要求与https://edu.cnblogs.com/campus/nenu/2018fall/homework/2246相同 一.小组介绍 组长:刘莹莹 组员:朱珅莹 孙韦男 祝玮琦 王玉潘 周 ...

  3. Wordpress 加载 js 文件到底部

    wp_enqueue_script wp_enqueue_script( string $handle, string $src = '', array $deps = array(), string ...

  4. C语言——第四次作业(2)

    作业要求一 项目wordcount 设计思路:输入需统计的文件名,打开此文件,输入功能对应的字符,分别实现对应的功能,关闭文件. 主要代码 #include<stdio.h> #inclu ...

  5. oracle用expdp定时备份所有步骤详解[转]

    用oracle命令备份数据库,生成dmp文件,保存了整一套的用户及表数据信息.还原简单.加上widnows的批处理bat命令,实现每天0点备份,现把经验送上给大家! 工具/原料   oracle11g ...

  6. pandas dataframe 读取 xlsx 文件

    refer to: https://medium.com/@kasiarachuta/reading-and-writingexcel-files-in-python-pandas-8f0da449c ...

  7. laravel 创建自定义全局函数

    全局函数的实现是依靠在初始化的时候,将helps.php或者functions.php直接进行了加载.而Laravel中bootstrap/autoload.php(laravel 5.5 貌似没有这 ...

  8. 转 HTTP.SYS 详解

    http.sys 是一个位于Win2003和WinXP SP2中的操作系统核心组件, 能够让任何应用程序通过它提供的接口,以http协议进行信息通讯. 温馨提示:如果用户不慎删除了该驱动文件,不用担心 ...

  9. BUG的定位与分析思路

    一般来说bug大多数存在于3个模块: 1.前台界面,包括界面的显示,兼容性,数据提交的判断,页面的跳转等等,这些bug基本都是一眼可见的,不太需要定位,当然也不排除一些特殊情况,本身数据传过来的时候就 ...

  10. Phonegap 通信原理

    下图为JavaScript调用本地代码的通信过程 Phonegap的核心API都是基于插件的,这些JavaScript API都会调用cordova.exec() 函数来完成操作.cordova.ex ...