Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Examples of Python any parameters     - Java environment to build a number of issues (Linux)

- Java in several ways of using MongoDB (Programming)

- Fedora 20 installation source Xen4.3.0 (Linux)

- Install Java, Maven, Tomcat under Linux (Linux)

- Linux mention the right notes (Linux)

- How to install Eclipse Luna IDE on CentOS 7 / RHEL 7 (Linux)

- Initialization and starting process of Linux (Linux)

- Mac OS X 10.10 Yosemite compiling OpenJDK 9 (Linux)

- CentOS 6.5 installation VNCServer implement graphical access (Server)

- CentOS 7 open ports (Linux)

- Linux System Getting Started Tutorial: how to find information on Linux-embedded module (Linux)

- installation and configuration of the PHP environment (Apache2) under Linux (Server)

- Upgrading to Debian 7.6 glibc 2.15 (Linux)

- Linux common network tools: hping Advanced Host Scan (Linux)

- How to Use Nmap security scanner tool on Linux (Linux)

- Installation under Linux Mint system guidelines for Gtk (Linux)

- Docker + OpenvSwitch build experimental environment VxLAN (Server)

- Experts teach you safety precautions Linux Sniffer (Linux)

- Linux performance monitoring and common commands Introduction (Linux)

- Linux System Getting Started Learning: hard disk partition, and to deal with traps (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:      
 
- Graphics of Java Tools (Programming)
- Eclipse distributed management using GitHub project development (Linux)
- Analysis of Java reflection mechanism (Programming)
- Use lsof restore accidentally deleted log files or database (Linux)
- ASP.NET 5 (vNext) Linux deployment (Server)
- Use OpenSSL to generate a certificate detailed process (Linux)
- Paint with Vim (Linux)
- Linux Network Security: nmap port scanning software (Linux)
- Java synchronization mechanism: synchronized, wait, notify (Programming)
- C ++ function object (Programming)
- When Linux Detailed time zone and common function of time (Linux)
- Fedora 22 installation and configuration optimization (Linux)
- Linux Mint under tty.js Installation Guide (Linux)
- Linux Security Module (LSM) Introduction (Linux)
- MySQL partition table Comments (Database)
- JavaScript cross-browser event object library (Programming)
- Linux Samba server-side structures and the use of the client (Server)
- Present Situation and Development Trend of firewall products (Linux)
- For the FreeBSD install Adobe Flash plug-in (Linux)
- These days have been tossing in the Linux under the ASP.NET 5, on the next in the other operating systems in the ASP.NET 5 or. NET applications, in order to complete the MS VM (CoreCLR) run is not far Reach, the effect of the application.

Cur
(Server)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.