[b0017] python 归纳 (三)_类名当参数传入
# -*- coding: UTF-8 -*-
"""
测试传入类名 总结:
似乎python里面的一切东西都可以当参数传入 函数或者方法 """
class Ab:
a=3 class Ac:
a=0 class MyFactory:
def get_instance(self,ins): # ins 输入 类
return ins() mf = MyFactory()
obj1 = Ab()
obj2 = mf.get_instance(Ab) print obj1.a
print obj1.a """
Out:
3
3
"""
[b0017] python 归纳 (三)_类名当参数传入的更多相关文章
- Python基本语法_函数属性 & 参数类型 & 偏函数的应用
目录 目录 前言 软件环境 Python Module的程序入口 函数的属性 Python函数的创建 函数的参数 必备参数 缺省参数 命名参数 不定长参数 匿名参数 偏函数的应用 前言 Python除 ...
- [b0022] python 归纳 (八)_多进程_基本使用
# -*- coding: UTF-8 -*- """ 测试进程使用 multiprocessing.Process 使用: 1. 准备一个函数<fun>,子 ...
- [b0038] python 归纳 (二三)_多进程数据共享和同步_队列Queue
1 队列读写 # -*- coding: utf-8 -*- """ 多进程 共享 队列 multiprocessing.Process 逻辑: 一个进程往队列写数据, ...
- [b0032] python 归纳 (十七)_线程同步_信号量Semaphore
代码: # -*- coding: utf-8 -*- """ 多线程并发同步 ,使用信号量threading.Semaphore 逻辑: 多个线程,对同一个共享变量 , ...
- [b0028] python 归纳 (十三)_队列Queue在多线程中使用
# -*- coding: UTF-8 -*- """ 多线程同时读队列 总结: 1. 会阻塞 if self._jobq.qsize() > 0 进入逻辑,此时被 ...
- [b0026] python 归纳 (十一)_线程_threading.Thread
总结: 默认父线程跑完,子线程并不会马上退出,不像 thread.start_threadXXXX 父线程跑完了,并没有退出,一直在那里 线程启动速度很快,不占多少开销,不到1毫 秒 代码: # -* ...
- [b0021] python 归纳 (七)_获得进程和线程信息
# -*- coding: utf-8 -*- """ 获得线程, 进程 ID,NAME 总结: """ import threading ...
- [b0018] python 归纳 (四)_运算符重载
# -*- coding: UTF-8 -*- """ 测试运算符重载 加法 总结: python 运算符表达式其实都是调用 类中方法 __xxx__ + <--- ...
- Python笔记(三)_字典与集合
字典dict 映射类型,以键-值的方式存储,通过键来取相应的值 member={'one':1,'two':2,'three':3} 创建字典member=dict('苹果'='apple','桔子' ...
随机推荐
- PHP将字符串转数组
explode(',',$arr_string) //将字符串转数组 $arr_string = '1,2,3'; $arr = explode(',',$arr_string); dump($arr ...
- [日常] 安装windows+deepin双系统
我的测试电脑上安装了三个系统,分别是win7 , ubuntu16.04 ,deepin15.11下面的步骤是安装deepin系统的过程 1.制作启动u盘,直接使用官方工具制作就可以了,我的已经制作好 ...
- 修改postgresql 密码
sudo -u postgres psql -c "alter user postgres password '123456';"
- unittest单元测试,基于java的junit测试框架
import unittestclass study(unittest.TestCase): def testXia(self): self.assertEqual((3*4),20) def tes ...
- gn gen ninja
- Ubuntu环境下打开Firefox报错: Firefox is already running, but is not responding.
在ubuntu下启动firefox可能会报错 Firefox is already running, but is not responding. To open a new window, you ...
- js 三种存储方式的区别
javaScript有三种数据存储方式,分别是: sessionStorage localStorage cookie 相同点:都保存在浏览器端,同源的 不同点: ①传递方式不同 cookie数据始终 ...
- PageHelper分页(十)
分页有两种: (1) 物理分页:物理分页依赖的是某一物理实体,这个物理实体就是数据库,比如MySQL数据库提供了limit关键字,程序员只需要编写带有limit关键字的SQL语句,数据库返回的就是分页 ...
- es6 的类 class
1.ES6提供了更接近传统语言的写法,引入了Class(类)这个概念,作为对象的模板.通过class关键字,可以定义类. 2. //定义类 class Point { constructor(x, y ...
- ESP8266 LUA脚本语言开发: 外设篇-定时器,延时,看门狗
https://nodemcu.readthedocs.io/en/master/modules/tmr/ local mytimer1 = tmr.create() function TimeFun ...