Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Python Basics Tutorial - lambda keyword     - Configuring ftp server and nfs server under Linux (Server)

- JavaScript function part (Programming)

- Run two MySQL service on one server (Database)

- TNS-03505 name could not be resolved (Database)

- In Debian 4.3 compiler under Linux-2.6.28 kernel Summary (Programming)

- Oracle index visible and hidden (visible / invisible) (Database)

- MongoDB learning Notes (2) basic connection example of -Nodejs and MongoDB (Database)

- CentOS 7.0 running Docker kernel error solution (Server)

- hadoop 2.7.1 High Availability Setup Deployment (Server)

- KVM add virtual disks (Linux)

- How to view information about the installed version of CentOS (Linux)

- Running the open-source Swift under Linux platform (Linux)

- Linux five security TIPS (Linux)

- Java logging performance of those things (Programming)

- To install and deploy PHP environment under the CentOS (Server)

- Oracle metadata Reconstruction experiments (Database)

- Ubuntu 14.04 / 14.10 how to install Mate 1.10.0 (Linux)

- Vim useful plugin: vundle (Linux)

- SSH without password Definitive Guide (Linux)

- CentOS Linux Optimization and real production environment (Linux)

 
         
  Python Basics Tutorial - lambda keyword
     
  Add Date : 2017-06-05      
         
         
         
  The Python lambda keyword can be understood as: its function is similar to function pointers. Official translation lambda is an anonymous function, which is relatively normal function is as an illustration:

Define a normal function, to achieve operation by 1:

def plus1 (x):
    return x + 1

The above statements are implemented:
1. Define a function, the function is named: plus1
2. This function has one argument

Corresponding anonymous function statement writing:

lambda x: x + 1

Note that this is an expression, so he actually can not do anything. . .

So if we want to call the function to achieve operational by 1, respectively, by way of example for normal function and the anonymous function is as follows:

Function to achieve real name:

def plus1 (x):
    return x + 1

a = 0
a = plus1 (a)
print a

Anonymous functions to achieve:

func = lambda x: x + 1
a = 0
a = func (a)
print a

Conclusion usage anonymous function both as a C language macro definitions, like a C language function pointer.

The anonymous function and branded functions in combination even more fun, such as:

def plus1 (x):
    return x + 1

func = lambda x: plus1 (x)
a = 0
a = func (a)
print a

You see, this is not a function pointer usage yet?

With the C language function pointer becomes extremely flexible, too, will spend after lambda, python can also become equally flexible.
     
         
         
         
  More:      
 
- Compile and install GCC 4.8.1 + GDB 7.6.1 + Eclipse in CentOS 6.4 in (Linux)
- Alternative methods of intrusion bundled executable file new thinking (Linux)
- Quickly locate the mistakes by gdb location (Programming)
- Haproxy multi-domain certificate HTTPS (Server)
- Mac OS X system setup Google Go language development environment configuration tool Sublime Text 2 (Linux)
- How to Install terminator 0.98 on Ubuntu and Linux Mint (Linux)
- Let MySQL 5.6 support Emoji expression (Database)
- iSCSI + multipath achieve DM multipath storage (Server)
- Category prevent DoS attacks against Linux (Linux)
- Two minutes thoroughly so that you understand Android Activity Lifecycle (Programming)
- After VMware CentOS full VM clone the network card is unavailable Solutions (Linux)
- Oracle 11g RMAN virtual private directory (Database)
- Under CentOS using yum command to install the Task Scheduler crontab (Linux)
- Linux RPM (Linux)
- C ++ casts New Standard Comments (Programming)
- How to use Aptik to backup and restore Apps/PPAs under ubuntu (Linux)
- init level settings for Linux / etc / inittab file into six (restart) or does not support the level of solution (Linux)
- Text editing and viewing text Linux command (Linux)
- Linux port mapping system (routing and forwarding) (Server)
- Editor of the popular Linux Gvim (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.