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' ...
随机推荐
- LVM---动态调整磁盘容量
LVM:logical volume manager(逻辑卷管理):LVM屏蔽了底层磁盘布局,方便于动态调整磁盘容量. 一.创建逻辑卷的步骤: 1)通过fdisk 工具将磁盘转换为linux分区 2) ...
- rsync 同步文件
rsync 同步文件 rsync -avz roo@192.168.4.12::/home/a ./a --exclude "data" exclude 去掉/a/data 文件 ...
- 我的Android最佳实践之—— Android启动画面的实现方法
本文实例讲述了Android启动画面的实现方法.分享给大家供大家参考.具体分析如下: 在应用程序中经常用到启动画面,会启动一个后台线程为主程序的运行准备资源.Android要实现启动画面可以这样做: ...
- Web上传文件
客户端 相对于FTP文件上传,Web文件上传速度慢一些,但使用方便,不需要客户端,而且权限比FTP容易控制. Web文件上传采用POST方式,上传文件需要设置FORM的entype属性为 ...
- nginx软负载的搭建
Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器,在高连接并发的情况下Nginx 是 Apa ...
- SOA_环境安装系列2_Oracle RCU安装和环境搭建(案例)
2015-01-02 Created By BaoXinjian
- 帝国CMS常见问题记录
1.第一次安装,为什么找不到"增加信息"的地方?因为你未增加栏目,请先增加栏目,然后再增加信息(终极栏目下方可增加信息). 2.为什么信息管理的"信息栏目"列表不变?缓存问题,解决方法如下两种:1." ...
- haxm intelx86加速模拟器的安装
http://blog.csdn.net/huang9012/article/details/18082601 如果安装了还出现 创建模拟器 选项 CPU/abi的时候还出现 no system im ...
- Session 与cookies 的区别
两个都可以用来存私密的东西,同样也都有有效期的说法. 区别在于:session是放在服务器上的,过期与否取决于服务期的设定,cookie是存在客户端的,过去与否可以在cookie生成的时候设置进去. ...
- bootstrap-输入框组
<!-- input-group 只能针对输入框,输入框组 input-group-addon 给输入框前后添加的额外元素 input-group-btn 添加的额外元素是按钮: --> ...