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的更多相关文章

  1. SSH项目练习的时候报错:[applicationContext.xml]: Invocation of init method failed;

    这里是控制台的报错信息:org.springframework.beans.factory.BeanCreationException: Error creating bean with name ' ...

  2. 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 ...

  3. 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 ...

  4. java代码中init method和destroy method的三种使用方式

    在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...

  5. 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 ...

  6. 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: ...

  7. 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' ...

  8. spring init method destroy method

    在java的实际开发过程中,我们可能常常需要使用到init method和destroy method,比如初始化一个对象(bean)后立即初始化(加载)一些数据,在销毁一个对象之前进行垃圾回收等等. ...

  9. 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' ...

随机推荐

  1. Centos7安装Zabbix3.0

    1.安装服务器端包 #rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch. ...

  2. beego里面自定义配置文件

    beego编译好的exe通过全路径调用会crash,看了半天,发现是解析不到配置文件,研究了下 发现beego自定义配置文件以后,需要手工parse,我表示,以为是自动化的,没想到是半自动化的…… 追 ...

  3. HDU3530 子序列

    题目大意:给出一串长度为n的整数串,求最长的一个连续子序列,满足该序列中最大的元素与最小的元素之差大于等于m, 并且小于等于k.n<=100000 分析:维护两个单调队列,一个递增的,维护最小值 ...

  4. js工具类 ----正则

    function(value){  if(value){   var reg=new RegExp("^[a-zA-Z0-9_-]+$");   return reg.test(v ...

  5. 【转】sql server2005中raiserror的用法

    raiserror  是由单词 raise error 组成     raise  增加; 提高; 提升 raiserror 的作用: raiserror 是用于抛出一个错误.[ 以下资料来源于sql ...

  6. ACL权限设置使用

    acl操作 # 查看操作的分区支不支持acldumpe2fs -h /dev/sda2 | grep aclDefault mount options: user xattr acl 代表支持acl如 ...

  7. css设置背景图片,ie显示不了

    本来是想给导航栏<div class="nav"></div>添加背景图片的,设置css样式如下: .nav{background:url("ht ...

  8. Linux Tcpdump 使用举例 ---持续更新

    举例: 保存到文件tcpdump -w xxx.cap(默认抓取eth0的包) 抓eth1的包 tcpdump -i eth1 -w /tmp/xxx.cap 抓到完成的数据包(默认只抓前68字节) ...

  9. python 判断内网IP方法及实例应用

    一.初衷: 一般在CMDB里会存储一台服务器的内网IP.管理IP.电信IP.联通IP,我们在使用的时候只需要拿到其中一个外网IP地址即可.那么我们就需要判断内网IP.管理IP并剔除掉,获取第一个外网I ...

  10. Android 开发中常用 ADB 命令总结

    adb 的全称为 Android Debug Bridge,就是起到调试桥的作用.通过 adb 我们可以在 Eclipse 中方便通过 DDMS 来调试 Android 程序,说白了就是 debug ...