what is the different between function and method in python
来源:互联网 发布:tomcat启动源码 编辑:程序博客网 时间:2024/05/21 10:46
Recently, I’m concentrating on nose plugin development.
Some people would be confused with some descriptions in http://nose.readthedocs.io/en/latest/plugins/interface.html
wantFunction(function)Return true to collect this function as a test, false to prevent it from being collected, and None if you don’t care.Parameters: function – The function object being examined by the selectorwantMethod(method)Return true to collect this method as a test, false to prevent it from being collected, and None if you don’t care.Parameters: method (unbound method) – The method object being examined by the selector
what is the different between function and method?
After some experiments, we get the conclusion below:
- function is defined out of class in python
- method is defined in a class
>>> def a(): pass>>> a<function a at 0x107063aa0>>>> type(a)<type 'function'>>>> class A:... def a(self): pass>>> A.a<unbound method A.a>>>> type(A.a)<type 'instancemethod'>
import unittestdef test_function(): print "test_function will be invoked by wantFunction"class TestStringMethods(unittest.TestCase): def test_method(self): print "test_method will be invoked by wantMethod"
0 0
- what is the different between function and method in python
- What is the difference between BIT and TINYINT in MySQL
- What is the difference between fprintf and vfprintf in C++?
- what is the difference between definition and declaration in c
- what is the difference between _source and _all in Elasticsearch
- What is the different between a Cluster and MPP supercomputer architecture?
- What is different between ClassLoader.getResourceAsStream() and Class.getResourceAsStream()?
- c++ what is different between map and hash_map
- the different between function and procedure in oracle oracle 中函数和存储过程的区别
- What is the difference between test, [ and [[ ?
- what's annotations is in java? what's the relationship between annotation and reflection?
- What is the difference between a parametric learning algorithm and a nonparametric learning method?
- What is the difference between -I and -L in makefile? and the means of -d.
- What's different between INDEX and KEY in database
- what's the different between forward proxy and reverse proxy?
- In C++, what’s the difference between an inline function and a macro?
- What exactly is the difference between “pass by reference” in C and in C++?
- What is the difference between Sprint and Iteration in Scrum and length of each Sprint?
- Insert Image using Spring JdbcTemplate
- js知识点
- 安装cocoapods
- datatable参数和服务端ajax函数配置及说明
- AngularJS——checkbox ng-checked的应用(回写:带真实案例代码)
- what is the different between function and method in python
- Map集合中value()方法与keySet()、entrySet()区别
- git删除目录
- windows核心编程系列学习记录3——内核对象
- XPath Cookbook-节点
- A1074. Reversing Linked List (25)
- jdbcTemplate更新mysql的blob类型字段
- 27:Reverse Linked List
- quartz集群调度机制调研及源码分析