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. C++设计模式之职责链模式

    代码实现: // chainResbonsibility.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <stri ...

  2. SQL (FMDB)

    sql常用语句 创建表 CREATE TABLE IF NOT EXISTS "T_Person" ( "id" INTEGER NOT NULL PRIMAR ...

  3. STL标准库-容器-unordered_set

    技术在于交流.沟通,本文为博主原创文章转载请注明出处并保持作品的完整性 unordered_set与与unordered_map相似,这次主要介绍unordered_set unordered_set ...

  4. vue.js 源代码学习笔记 ----- text-parse.js

    /* @flow */ import { cached } from 'shared/util' import { parseFilters } from './filter-parser' //找到 ...

  5. Linux:root下的文件-anaconda-ks.cfg详解

    anaconda-ks.cfg详解 系统安装的时候生成的一个文件,通过这个文件可以修改成自动安装的脚本,用于自动安装同样配置的系统. 自动生成的启动文件anaconda# Kickstart file ...

  6. js 验证手机号码

    js 验证手机号码 //验证手机号        function isMobel(value) {           if (/^1[3-8]+\d{9}$/g.test(value)) {    ...

  7. [笔记]CodeIgniter的SESSION

         由于HTTP协议本身是无状态的,所以当保留某个用户的访问状态信息时,需要客户端有一个唯一标识传给服务端,这个唯一标识就是SESSION ID,存放在客户端的COOKIE中,然后服务端根据该标 ...

  8. 《DSP using MATLAB》Problem 2.9

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  9. python functiontools 模块

    一个内置的模块.  作用是实现了更多的功能, 同时形式上显得很简洁.    虽然在使用很方便, 但其中的原理还是很难复杂的. ------------------------------------- ...

  10. python 中datetime 和 string 转换

    dt = datetime.datetime.strptime(string_date, fmt) fmt 的格式说明如下: https://docs.python.org/2/library/dat ...