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

    题解: 有上限的网络流 基本模板 代码: #include<bits/stdc++.h> using namespace std; ; int ne[N],num,n,m,d[N],S,T ...

  2. oracle过滤某个字段重复记录,只获取一条记录

    一,首先想到: 1,关键字distinct 2,group by 3,MAX,MIN这样的函数被称为聚集函数,和GROUP搭配起来用 但均无法实现,执行结果如下 举例: 表名:OffsiteOutre ...

  3. @InitBinder装配自定义编辑器

    @InitBinder装配自定义编辑器 第一步:BaseController.java,标注@InitBinder public class BaseController { @InitBinder ...

  4. 实现react中的自动保存--定时任务

    1. 定义和用法 setInterval() 方法可按照指定的周期(以毫秒计)来调用函数或计算表达式. setInterval() 方法会不停地调用函数,直到 clearInterval() 被调用或 ...

  5. 使用 Win2D 绘制带图片纹理的圆(或椭圆)

    使用 Win2D 绘制图片和绘制椭圆都非常容易,可是如何使用 Win2D 绘制图片纹理的椭圆呢? 本文内容 重力迷宫小球 Win2D 实现 关于 CanvasCommandList 重力迷宫小球 ▲ ...

  6. Struts2自定义标签4自定义分页标签

    第一步:webroot/web-inf下的str.tld文件 <?xml version="1.0" encoding="UTF-8"?> < ...

  7. Linux下定时切割Mongodb数据库日志并删除指定天数前的日志记录

    此为在网络上找来的,觉得很好! 实现目的: 对Mongodb数据库日志按天保存,并且只保留最近7天的日志记录. 具体操作: 使用Mongodb数据库自带的命令来切割日志 ps -def | grep ...

  8. win7 安装redis服务

    Redis官方是不支持windows的,只是 Microsoft Open Tech group 在 GitHub上开发了一个Win64的版本,项目地址是: https://github.com/MS ...

  9. windows下php7安装redis扩展

    windows下php7安装redis扩展windows下开发用的wamp集成的环境,想装个php-redis扩展.php_redis.dll下载地址:https://pecl.php.net/pac ...

  10. bzoj1925(SCOI2010)地精部落

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1925 要怎样才能想出正解呢? 当然有一维表示从1到 i . 发现最后是递增的方案数=最后是递 ...