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. android学习笔记13——ExpandableListView

    ExpandableListView==>可展开的列表组件 ==> ExpandableListView是ListView的子类,对其进行了扩展,其将应用中的列表项分为几组,每组中又包含多 ...

  2. ubuntu eclipse下配置C++ 环境

    首先你通过以下3个命令确定已安装好eclipse cdt sudo apt-get install eclipse sudo apt-get install eclipse-pde sudo apt- ...

  3. Sublime text2用户自定义配置

    [{ "keys": ["ctrl+d"], "command": "run_macro_file", "ar ...

  4. Navicat(连接) -1之Navicat Cloud

    Navicat Cloud Navicat Cloud 提供一个云服务,同步不同机器和平台的 Navicat 连接.查询.模型和虚拟组.当添加一个连接到 Navicat Cloud,它的连接设置和查询 ...

  5. window下安装oracle数据库

    Oracle 11g安装 1.解压下载的包,然后进入包内,点击setup.exe开始安装 . 2.出现如下:一般把那个小对勾取消,点击下一步进行, 弹出下图这个后点‘是’ 3.下图后,选择创建和配置数 ...

  6. 不能向Github提交某一類型的文件

    之前在github上建了6個project,但是其中有一個不能提交jar文件,其他的都可以.後來發現原來在項目中有一個叫.gitignore的文件,其他項目里的都是/bin,但是那個不能提交jar的項 ...

  7. 证书 pki

    对称加密         symmetric cryptographic 非对称加密     asymmetric cryptographic 密钥交换协议 key agreement/exchang ...

  8. ruby1.8到2.1语法改变

    1定义hash的语法改变old_way = {:foo => "bar", :one => 1}new_way = {foo: "bar", one ...

  9. LK光流算法:提高计算精度和增加搜索范围

    LK光流算法:提高计算精度和增加搜索范围 关于LK算法的基本理论,见:http://www.cnblogs.com/dzyBK/p/4960630.html 这里主要阐述如何提高LK算法的计算精度和在 ...

  10. [kuangbin带你飞]专题七 线段树

            ID Origin Title 228 / 440 Problem A HDU 1166 敌兵布阵   207 / 438 Problem B HDU 1754 I Hate It   ...