The init method
The init method is a special method that gets invoked when an object is instantiated. Its full name is __init__ (two underscore characters, followed byinit, and then two more underscores). An init method for the Time class might look like:
def __init__(self,hour=0,minute=0,second=0):
self.hour = hour
self.minute = minute
self.second = second
It is common for the parameters of __init__ to have the same names as the attributes. The parameters are optional, so if you call Time with no arguments, you get the default values. If you provide one argument, it overrides hour. If you provide two arguments, they override hour and minute. And if you provide three arguments, they override all three default values.

from Thinking in Python
The init method的更多相关文章
- SSH项目练习的时候报错:[applicationContext.xml]: Invocation of init method failed;
这里是控制台的报错信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' ...
- Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; neste
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFacto ...
- Invocation of init method failed; nested exception is org.hibernate.HibernateException: could not instantiate RegionFactory [org.hibernate.cache.impl
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- java代码中init method和destroy method的三种使用方式
在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...
- MyBatis笔记----报错:Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/ij34/mybatis/applicationContext.xml]: Invocation of init method failed; nested exception is org.sp
四月 05, 2017 4:51:02 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRef ...
- org.springframework.beans.factory.BeanCreationException,Invocation of init method failed,Context initialization failed
G:\javaanzhuang\apache-tomcat-\bin\catalina.bat run [-- ::,] Artifact ssm_qingmu02_web:war exploded: ...
- Invocation of init method failed; nested exception is java.text.ParseException: '?' can only be specfied for Day-of-Month or Day-of-Week.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cronTrigger' ...
- spring init method destroy method
在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...
- aused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method fai
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'roleDaoImpl' ...
随机推荐
- c++的历史-异常
1.异常出现的目的 在c++语言的设计和演化中,Bjarne Stroustrup说过异常的设计假定如下情况: 基本上是为了处理错误 与函数定义相比,异常处理是很少的 与函数调用相比,异常出现的频率较 ...
- Android框架
http://blog.163.com/vicent_zxb/blog/static/1858861312011488262665/ (一)Android系统框架详解 Android采用分层的架构,分 ...
- c++随机数生成
算机的随机数都是由伪随机数,即是由小M多项式序列生成的,其中产生每个小序列都有一个初始值,即随机种子.(注意: 小M多项式序列的周期是65535,即每次利用一个随机种子生成的随机数的周期是65535, ...
- ADF_ADF Faces系列2_使用JSF开发基于Ajax的用户界面:ADF Faces富客户端组件简介(Part2)
2013-05-01 Created By BaoXinjian
- PO_PO系列 - 询价报价单管理分析(案例)
2014-07-01 Created By BaoXinjian
- Form_Form Builder编译fmb/library/menu方式总结(汇总)
2014-12-27 Created By BaoXinjian
- Oracle数据库 External component has thrown an exception
出现这种错误一般是在SQL语句执行前就报出的错误.这样的错误一般需要仔细检查SQL语句,以及参数的数据类型. 而在cmd.ExecuteNonQuery()中出现的错误,则很可能就排除了语法类的错误. ...
- invalid byte 1 of 1-byte UTF-8 sequence
这是一个很普通的问题 , 就是UTF-8的xml文件被默认为GBK或者其他编码的编辑器改了之后保存为其他编码了 , 解决方案网上有很多. 其实需要注意的就是不要为了图方便 , 随便就找了个编辑器改一下 ...
- android 基本知识
307966990 lyd@itcast.com 13716040037 李印东 东东 通信技术: 1G 模拟制式 语音通话. 2G GSM, CDMA 收发短信和邮件. 2.5G GPRS, EDG ...
- Beautiful Soup第三方爬虫插件
什么是BeautifulSoup? Beautiful Soup 是用Python写的一个HTML/XML的解析器,它可以很好的处理不规范标记并生成剖析树(parse tree). 它提供简单又常用的 ...