python code(1)
from collections import UserList
class MthChianList(UserList):
def filter(self,predicste):
return MthChianList(elem for elem in self if predicste(elem))
def map(self,mapper):
return MthChianList(mapper(elem) for elem in self)
def for_each(self,action):
for elem in self:
action(elem)
lt=MthChianList(['A','B','c','d','e','F'])
lt.filter(str.islower).map(str.upper).for_each(print)
python code(1)的更多相关文章
- Exploring Python Code Objects
Exploring Python Code Objects https://late.am/post/2012/03/26/exploring-python-code-objects.html Ins ...
- 机器学习算法实现(R&Python code)
Machine Learning Algorithms Machine Learning Algorithms (Python and R) 明天考试,今天就来简单写写机器学习的算法 Types Su ...
- How to run Python code from Sublime
How to run Python Code from Sublime,and How to run Python Code with input from sublime Using Sublime ...
- Python code 提取UML
Python是一门支持面向对象编程的语言,在大型软件项目中,我们往往会使用面向对象的特性去组织我们的代码,那有没有这样一种工具,可以帮助我们从已有代码中提取出UML图呢?答案是有的.以下,我们逐个介绍 ...
- PEP 8 – Style Guide for Python Code
原文:PEP 8 – Style Guide for Python Code PEP:8 题目:Python代码风格指南 作者:Guido van Rossum, www.yszx11.cnBarry ...
- Change the environment variable for python code running
python程序运行中改变环境变量: Trying to change the way the loader works for a running Python is very tricky; pr ...
- python code
执行动态语句 执行字符串中的代码 http://www.cnblogs.com/fanweibin/p/5418817.html #!usr/bin/env python #coding:utf-8 ...
- Python——Code Like a Pythonista: Idiomatic Python
Code Like a Pythonista: Idiomatic Python 如果你有C++基础,那学习另一门语言会相对容易.因为C++即面向过程,又面向对象.它很底层,能像C一样访问机器:它也很 ...
- python code 1_username registration & login
This tiny program consists of 2 parts - registration and login. In the part of registration, the key ...
- python code practice(二):KMP算法、二分搜索的实现、哈希表
1.替换空格 题目描述:请实现一个函数,将一个字符串中的每个空格替换成“%20”.例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy. 分析: 将长度为 ...
随机推荐
- stark组件之搜索【模仿Django的admin】
一.先看下django的admin是如何做搜索功能的 配置一个search_fields的列表就可以实现搜索的功能 class testbook(admin.ModelAdmin): # 第一步,定义 ...
- Pyqt5的事例讲解
1.第一个gui程序 import sys from PyQt5.QtWidgets import QApplication from PyQt5.QtWidgets import QMainWind ...
- 检测Android手机的IP地址
package com.jason.demo.androidip; import android.content.Context; import android.net.DhcpInfo; impor ...
- Linux磁盘分区与文件系统
一 Linux磁盘分区与文件系统 在Linux中常见的操作系统有:ext2 ext3 ext4 xfs btrfs reiserfs等文件系统的作用主要是明确磁盘或分区上的文件存储方法以及数据结构,L ...
- .net 技术地图
以下是技术牛人,灵感之源.在于15年7月23日归类的一个技术地图 主要包括10个大类.50个子类 http://jingyan.baidu.com/article/4ae03de344f9b33eff ...
- find和find_if,value_type
find算法:返回 [first,end)中第一个值等于value元素的位置 线性复杂度:最多比较次数:元素的总个数 find函数的最后一个参数,必须是string,float,char,double ...
- 让键盘输入不影响界面的动态效果(C++)
输入语句,当代码运行到它的时候就要等待输入,才能执行下一行代码,如果不输入的话,就相当于在这里暂停了(程序设计老师讲过通过这样的方式以达到暂停(pause)的效果),但如果我们想要如果没输入仍然可以运 ...
- lua 2.2 变种
1.修改 ~= 操作符为 != 2.取消 --[[ ]] 多行注释语法 下载源码
- sys安装
1.将SYS驱动文件放到系统目录的SYSTEM32目录中.2.按WIN+R组合键,在运行框中输入:regsvr32 sys所在全路径,点击确定即可.
- Null value was assigned to a property of primitive type setter of cn.itcast.oa.domain.Forum.topicCount
[引用http://m.blog.csdn.net/blog/u013998070/41087351] Null value was assigned to a property of primiti ...