Python : Data Encapsulation
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的更多相关文章
- 【Python学习笔记】Coursera课程《Python Data Structures》 密歇根大学 Charles Severance——Week6 Tuple课堂笔记
Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week6 Tuple 10 Tuples 10.1 Tuples A ...
- Objective-C Data Encapsulation
All Objective-C programs are composed of the following two fundamental elements: Program statements ...
- 《Python Data Structures》Week5 Dictionary 课堂笔记
Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week5 Dictionary 9.1 Dictionaries 字 ...
- 《Python Data Structures》 Week4 List 课堂笔记
Coursera课程<Python Data Structures> 密歇根大学 Charles Severance Week4 List 8.2 Manipulating Lists 8 ...
- Python Data Visualization Cookbook 2.2.2
import csv filename = 'ch02-data.csv' data = [] try: with open(filename) as f://用with语句将数据文件绑定到对象f r ...
- python data analysis | python数据预处理(基于scikit-learn模块)
原文:http://www.jianshu.com/p/94516a58314d Dataset transformations| 数据转换 Combining estimators|组合学习器 Fe ...
- 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 ...
- [Machine Learning with Python] Data Preparation through Transformation Pipeline
In the former article "Data Preparation by Pandas and Scikit-Learn", we discussed about a ...
- [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 ...
随机推荐
- linux Sersync 参数说明
Sersync 的可选功能是通过 xml 配置文件来实现的,下面来为大家解释该文件! 在该文件中,使用<!--中间是注释内容-->的方式去注释信息,注意不是我们平时# [root@SERS ...
- 380-Xilinx Kintex UltraScale FPGA KCU1500 Acceleration Development Kit
Xilinx Kintex UltraScale FPGA KCU1500 Acceleration Development Kit Product Description The Kintex® U ...
- 理解uboot过程中的优秀博客
To_run_away的博客 https://blog.csdn.net/qq_16777851/column/info/28098/5 加了微信好友,公众号也有文章. Camus https://c ...
- nodepad++如何多行同时编辑
notepad++ 可以选中alt按键进行选择 支持同时编辑多行
- alert(1) to win 15
- Robomongo可视化命令
## 更新命令示例 db.getCollection('collection_name').update( {'_id':ObjectId('id string')}, {$set:{' ...
- js中关键字 const , let , var 的用法区别
1.const定义的变量不可以修改,而且必须初始化. 2.var定义的变量可以修改,如果不初始化会输出undefined,不会报错. 3.let是块级作用域,函数内部使用let定义后,对函数外部无影响 ...
- springboot 中的 thymeleaf 页面进阶小知识
我们做好了登录页,那设计一个场景吧,比如我们登录后跳转到公司主页,想从公司主页再跳转到员工列表页: 这样的场景我们该如何实现,首先要知道一些基础知识,就是SpringBoot的一些关于请求的架构知识: ...
- Usage of hdf2v3 and hdf2file
备注 修改Filetype,再执行hdf2file或hdf2tab,可以输出不同类型的数据.把Filetype设置成8,就是 Tecplot 格式的数据. <!DOCTYPE html PUBL ...
- vim 批量添加删除注释
vim中单行注释只是多行注释的一个特例,这里统一进行多行注释的讲解 (1)添加批量注释 ctrl+v 进入列编辑模式,向下或向上移动光标,把需要注释的行的开头标记起来,然后按大写的I(shift+i) ...