Python : Data Encapsulation

The following table shows the different behaviour:

Name Notation Behaviour
name Public Can be accessed from inside and outside
_name Protected Like a public member, but they shouldn't be directly accessed from outside.
__name Private Can't be seen and accessed from outside

e.g.

class Account(object):
counter = 0
def __init__(self, holder, number, balance,credit_line=1500):
Account.counter += 1
self.__Holder = holder
self.__Number = number
self.__Balance = balance
self.__CreditLine = credit_line
def __del__(self):
Account.counter -= 1

  

												

Python : Data Encapsulation的更多相关文章

  1. 【Python学习笔记】Coursera课程《Python Data Structures》 密歇根大学 Charles Severance——Week6 Tuple课堂笔记

    Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week6 Tuple 10 Tuples 10.1 Tuples A ...

  2. Objective-C Data Encapsulation

    All Objective-C programs are composed of the following two fundamental elements: Program statements ...

  3. 《Python Data Structures》Week5 Dictionary 课堂笔记

    Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week5 Dictionary 9.1 Dictionaries 字 ...

  4. 《Python Data Structures》 Week4 List 课堂笔记

    Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week4 List 8.2 Manipulating Lists 8 ...

  5. Python Data Visualization Cookbook 2.2.2

    import csv filename = 'ch02-data.csv' data = [] try: with open(filename) as f://用with语句将数据文件绑定到对象f r ...

  6. python data analysis | python数据预处理(基于scikit-learn模块)

    原文:http://www.jianshu.com/p/94516a58314d Dataset transformations| 数据转换 Combining estimators|组合学习器 Fe ...

  7. Python Data Science Toolbox Part 1 Learning 1 - User-defined functions

    User-defined functions from:https://campus.datacamp.com/courses/python-data-science-toolbox-part-1/w ...

  8. [Machine Learning with Python] Data Preparation through Transformation Pipeline

    In the former article "Data Preparation by Pandas and Scikit-Learn", we discussed about a ...

  9. [Machine Learning with Python] Data Preparation by Pandas and Scikit-Learn

    In this article, we dicuss some main steps in data preparation. Drop Labels Firstly, we drop labels ...

随机推荐

  1. Simple Vedio Intercom System

    I. Deployment  / Architecture Block Diagram II. Resources Used sip proxy server + sip user agent 1.  ...

  2. ll字段 详解 文件权限

    文件类型和权限 硬链接总数 属主用户名 属组组名 文件大小(字节) 上次修改时间 文件/目录名 drwxr-xr-x 15 lb lb 4096 10月 19 01:11 ./ drwxr-xr-x ...

  3. [NOI2004]郁闷的出纳员(平衡树)

    [NOI2004]郁闷的出纳员 题目链接 题目描述 OIER公司是一家大型专业化软件公司,有着数以万计的员工.作为一名出纳员,我的任务之一便是统计每位员工的工资.这本来是一份不错的工作,但是令人郁闷的 ...

  4. prototype的用法

    定义: prototype 属性使您有能力向对象添加属性和方法. 语法: object.prototype.name=value 实例: function prot(){ this.name = 'J ...

  5. Java文件处理之FileReader可输出中文字符

    import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; public ...

  6. CUDA Error

    第一个问题:CUDA Error: out of memory darknet: ./src/cuda.c:36: check_error: Assertion `0' failed. 已放弃 (核心 ...

  7. SpringCLoud之搭建Zuul网关集群

    1.使用技术 Springboot,SpringCloud,Zuul,Nignx 2.目的 使用Zuul搭建微服务高可用的网关 3.项目创建 3.1 创建注册中心(略) 3.2 创建一个hello-s ...

  8. 编辑器直接word直接上传word里的图片

    tinymce是很优秀的一款富文本编辑器,可以去官网下载.https://www.tiny.cloud 这里分享的是它官网的一个收费插件powerpaste的旧版本源码,但也不影响功能使用. http ...

  9. luogu P1020 导弹拦截 x

    首先上题目~ luogu P1020 导弹拦截 题目描述 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统.但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都 ...

  10. linux之yum源的RPM软件包管理

    1.yum源的配置文件 路径:vim /etc/yum.repos.d/CnetOS-Base.repo 文件格式: 2.yum查询 yum list 查询所有可用软件包 yum search 包名 ...