Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Examples of Python any parameters     - CentOS 6.6 install JDK7 (Linux)

- Ubuntu under Spark development environment to build (Server)

- MariaDB phpMyAdmin installation and configuration issues to resolve under CentOS7 (Database)

- Linux system security configuration (Linux)

- Python class of operator overloading (Programming)

- Via Twitter how open source library to be used anywhere Emoji emoticons (Linux)

- Talk Packages (Linux)

- Physical backup and recovery SYSTEM table space (Database)

- Fast Learning Clojure (Programming)

- Two kinds of agents of Spring AOP (Programming)

- A process of how to get the current traffic in GNU Linux (Linux)

- Terminal fun: 6 interesting Linux command-line tools (Linux)

- Android Studio simple setup (Linux)

- Debian 7.6 install Nvidia graphics driver (Linux)

- Shell Programming points to note about the function (Programming)

- An example of troubleshooting of embedded Linux OpenWRT (Linux)

- JDK installation notes under CentOS (Linux)

- TPCC-MySQL Benchmark (Database)

- Linux Basics Tutorial: Linux Kickstart automated installation (Linux)

- CentOS yum source configuration (Linux)

 
         
  Examples of Python any parameters
     
  Add Date : 2018-11-21      
         
         
         
  Collection parameters:

In the function definition, the collection of location parameters do not match the tuple.

>>> Def f (* args): print (args)

...

When this function is called, python relevant parameters for all positions collected into a new Ganso, and the assignment of this tuple to the variable args. (Can be indexed or stepping in for loop)

>>> F ()

()

>>> F (1)

(1,)

>>> F (1, 2, 3, 4)

(1, 2, 3, 4)

** Similar characteristics, but it is only valid for keyword arguments. These keyword arguments passed to the new dictionary.

>>> Def f (** args): print ((args)

...

>>> F ()

{}

>>> F (a = 1, b = 2)

{ 'A': 1, 'b': 2}

Another example:

>>> Def f (a, * pargs, ** kargs): print (a, pargs, kargs)

...

>>> F (1, 2, 3, x = 1, y = 2)

1 (2, 3) { 'y': 2, 'x': 1}

Unpack parameters

When you call the * syntax unpack parameter set.

>>> Def func (a, b, c, d): print (a, b, c, d)

...

>>> Args = (1, 2)

>>> Args + = (3, 4)

>>> Func (* args)

1234

Similarly, ** will be key-value pairs unpack a dictionary.

>>> Args = { 'a': 1, 'b': 2, 'c': 3}

>>> Args [ 'd'] = 4

>>> Func (** args)

1234

to sum up

* / ** Syntax: in the head, it means that any number of parameters were collected, and the call is unpack it any number of arguments.
     
         
         
         
  More:      
 
- Build their own recursive DNS server (Server)
- Oracle 11g RMAN cross-platform transfer table space (Database)
- How to understand Python yield keyword (Programming)
- 17 How to install the Ubuntu 14.04 and Linux Mint Kodi14 (XBMC) (Linux)
- The strings in Python reside (Programming)
- Let MySQL 5.6 support Emoji expression (Database)
- The Linux C truncate function clears the file notes (Programming)
- The user how to install Notepadqq 0.41.0 under ubuntu and debian (Linux)
- Debian 8 Jessie install LAMP server tutorial (Server)
- CV: Linux command displays the progress of the run command (Linux)
- CentOS installation pycurl (Linux)
- CentOS7 virtual machine settings, and bridging problems (Linux)
- Spring AOP custom annotation way to achieve log management (Programming)
- For the FreeBSD install Adobe Flash plug-in (Linux)
- Learn about EditText little depth (Programming)
- Redis is installed in Ubuntu 14.04 (Database)
- Log in CentOS 6.5 Multi-user setting VNC (Server)
- iOS developers - a simple factory pattern and OC reflection (Programming)
- Hadoop 2.6.0 standalone configuration and pseudo-distributed configuration under Ubuntu 14.04 (Server)
- Manager Docker browser (Server)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.