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 ...
随机推荐
- 记录卸载5.7版本MySQL并安装5.6版本MySQL
新版本有些问题很烦,也没时间去找解决办法,只好用回5.6,首先卸载6.7的MySQL: sudo apt-get autoremove --purge mysql-server-* apt remov ...
- 将ubuntu系统迁移到ssd固态
朋友送了一个固态硬盘给我,因此将原机械硬盘上的系统迁移到固态硬盘上. 原机械硬盘(dev/sdb)装有win10和ubuntu双系统.分区情况如下: sda1:ESP分区 sda2:资料 sda3:资 ...
- django之csrf_exempt解决跨域请求的问题
一: from django.views.decorators.csrf import csrf_exempt # 获取微信返回的code信息 @csrf_exempt def wechat_auth ...
- 小记:web安全测试之——固定session漏洞
今天因为项目背景需要,需要检测web接口是否一些安全隐患. 无奈于从未掌握有系统的渗透性知识,只好根据个人对网络协议和 web 的理解,做一些探索,最终发现了一个session fixation at ...
- 【leetcode】1042. Flower Planting With No Adjacent
题目如下: You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flow ...
- 【leetcode】1041. Robot Bounded In Circle
题目如下: On an infinite plane, a robot initially stands at (0, 0) and faces north. The robot can recei ...
- asp.net中的ORA-12154: TNS: 无法解析指定的连接标识符
本机PL/SQL能正常连接,但是asp.net连接有问题. 临时解决方案: <add key="ConnectString" value="Data Source= ...
- elasticsearch-head插件添加安全认证
elasticsearch-head是集群管理.数据可视化.增删查改.查询语句可视化工具;它可以对数据进行增删查改,对于数据安全来说是有风险的,因此在生产环境中尽量少用,使用该插件至少要限制ip地址或 ...
- shp文件导入数据库
数据库服务器(引擎) sql server oracle nosql sql语句... 从数据库端导入:新建数据库,导入shp文件 发布地图服务 jdbc.sdk
- 我的Podfile如下
# Uncomment this line to define a global platform for your projectuse_frameworks!(http://www.my516.c ...