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

  

				
时间: 2024-11-03 22:22:52

Python : Data Encapsulation的相关文章

Python Data Visualization Cookbook 2.2.2

1 import csv 2 3 filename = 'ch02-data.csv' 4 data = [] 5 6 try: 7 with open(filename) as f://用with语句将数据文件绑定到对象f 8 reader = csv.reader(f) 9 header = next(reader)//Python 3.X 用的是next() 10 data = [row for row in reader] 11 except csv.Error as e: 12 pri

pandas: powerful Python data analysis toolkit

pandas.read_csv pandas.read_csv(filepath_or_buffer, sep=', ', delimiter=None, header='infer', names=None, index_col=None, usecols=None, squeeze=False, prefix=None, mangle_dupe_cols=True, dtype=None, engine=None, converters=None, true_values=None, fal

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

原文:http://www.jianshu.com/p/94516a58314d Dataset transformations| 数据转换 Combining estimators|组合学习器 Feature extration|特征提取 Preprocessing data|数据预处理 1 Dataset transformations scikit-learn provides a library of transformers, which may clean (see Preproce

Python.Data.Analysis(PACKT,2014)pdf

下载地址:网盘下载 Finding great data analysts is difficult. Despite the explosive growth of data in industries ranging from manufacturing and retail to high technology, finance, and healthcare, learning and accessing data analysis tools has remained a challe

Up and Down the Python Data and Web Visualization Stack

摘自:http://nbviewer.ipython.org/gist/wrobstory/1eb8cb704a52d18b9ee8/Up%20and%20Down%20PyData%202014.ipynb USGS dataset listing every wind turbine in the United States: from collections import OrderedDict import bearcart import bokeh import bokeh.plott

Python For Data Science Cheat Sheet

1. Python Data Analysis Basics 2. Numpy 3. Scikit-Learn 4. Bokeh 5. Scipy 6. Pandas quote from http://www.jianshu.com/p/7f4945b5d29c 原文地址:https://www.cnblogs.com/aiden-liu/p/10773432.html

我要翻译《Think Python》-002 贡献列表 & 目录部分

PDF源文件地址 :  http://www.greenteapress.com/thinkpython/thinkpython.pdf 贡献列表 自从本书诞生之后,有超过上百个目光敏锐且有想法的读者给我发来了许多建议并指出了一些需要修正的地方.他们的热情和无私的奉献给了我巨大的帮助.如果你有任何建议或者发现需要修正的地方,请发邮件至:[email protected].如果您的建议被采纳,您的大名将会出现在我们的贡献人员列表(除非你本人过于低调拒绝承认).如果您发现文中的错误内容,敬请提供一下

Python类的内建方法-即所谓的魔术方法

在Python中以两个下划线开头的方法,__init__.__str__.__doc__.__new__等,被称为"魔术方法"(Magic methods).魔术方法在类或对象的某些事件出发后会自动执行,如果希望根据自己的程序定制自己特殊功能的类,那么就需要对这些方法进行重写.Python 将所有以 __包起来(即前后皆有__)的类方法保留为魔术方法. 注:如果只前面有双下划线__,则为私有方法或私有变量 一, A Guide to Python's Magic Methods Raf

Python——深入理解urllib、urllib2及requests(requests不建议使用?)

深入理解urllib.urllib2及requests            python Python 是一种面向对象.解释型计算机程序设计语言,由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年,Python 源代码同样遵循 GPL(GNU General Public License)协议[1] .Python语法简洁而清晰,具有丰富和强大的类库. urllib and urllib2 区别 urllib和urllib2模块都做与请求URL相关的操作,但