object and namespace
http://effbot.org/zone/python-objects.htm
几点总结:
(1) 类的基本属性
. id, returned by id(obj)
. type, returned by type(obj)
. some content
. methods; some objects have methods to change the content, and some don’t; eg, list vs. turple
. names
(2) namespace
. namespace are pairs of (name, object reference). eg., n=10 where ‘n’ is the name and ‘10’ is the int object.
. names are not really properties of objects
(3) assignment
举例说明。
name = 10
name = 20
. add name ‘name’ to local namespace, and refer it to an integer object containing value 10
. refer name to another integer object containing value 20
. the original object ‘10’ is not affected by this operation and it doesn’t care
再举一个object可变的例子。
name = []
name.append(a)
. add name ‘name’ to a local namespace, and refer it to an empty list object; this modifies the namespace
. an object method is called; this modifies the content of the the list object, but it doesn’t touch the namespace
(4) note
Things like name.attr and name[index] are just syntactic sugar for method calls.
The first corresponds to __setattr__/__getattr__, the second to __setitem__/__getitem__ (depending on which side of the assignment they appear).
--> syntactic suger是指为了更容易阅读而设计出来的编程语言的语法
object and namespace的更多相关文章
- Structure And Representation Of MIB Object Names - SNMP Tutorial
30.8 Structure And Representation Of MIB Object Names We said that ASN.1 specifies how to represent ...
- 设计模式之美:Extension Object(扩展对象)
索引 意图 结构 参与者 适用性 效果 相关模式 实现 实现方式(一):使用示例结构实现 Extension Object. 实现方式(二):使用泛型实现 IExtensibleObject<T ...
- Group Policy Object Editor
Group Policy Object Editor The Group Policy Object Editor is a tool that hosts MMC extension snap- ...
- [No000074]C#创建桌面快捷方式
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- JavaScript Patterns 5.4 Module Pattern
MYAPP.namespace('MYAPP.utilities.array'); MYAPP.utilities.array = (function () { // dependencies var ...
- Python 之作用域和名字空间
作用域与名字空间 Python有一个核心概念是名字空间(namespace),namespace是一个name到object 的映射关系,Python有很多namespace,因此,在代码中如果碰到一 ...
- 白话学习MVC(五)Controller的激活
一.概述 在此系列开篇的时候介绍了MVC的生命周期 , 对于请求的处理,都是将相应的类的方法注册到HttpApplication事件中,通过事件的依次执行从而完成对请求的处理.对于MVC来说,请求是先 ...
- Log4Net写入到数据库配置过程中的一些小问题备忘
问题1: 在公司进行log4net写入服务器配置的时候,一切正常,但是在家里的机器上,就频繁出现这个问题: SQL Server 2008 报错:已成功与服务器建立连接,但是在登录前的握手期间发生错误 ...
- <<编写可维护的JavaScript>>之避免使用全局变量
一.避免全局变量的理由 js中避免创建全局变量一是避免命名冲突,二是避免因为创建全局变量让代码变得脆弱,三是创建全局变量会让代码难以测试. 二.避免创建全局变量的几种方法 //避免全局变量 避免命名冲 ...
随机推荐
- ERROR 1872
解决 > start slave; ERROR (HY000): Slave failed to initialize relay log info structure from the rep ...
- oracle 删除掉重复数据只保留一条
用SQL语句,删除掉重复项只保留一条 在几千条记录里,存在着些相同的记录,如何能用SQL语句,删除掉重复的呢 .查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断 select ...
- thinkphp 范围标签
范围判断标签包括in notin between notbetween四个标签,都用于判断变量是否中某个范围. 大理石平台价格 IN和NOTIN 用法: 假设我们中控制器中给id赋值为1: $id = ...
- VC++ COMBO BOX控件的使用
1.你在编辑状态下点那个控件的向下的三角形,就出冒出来一个可以调高度的东东.将高度调高,否则在执行时会不能显示下拉选项. 2.为combo box添加选项,在编辑状态下选combo box控件的属 ...
- php算法题---对称的二叉树
php算法题---对称的二叉树 一.总结 一句话总结: 可以在isSymmetrical()的基础上再加一个函数comRoot,函数comRoot来做树的递归判断 /*思路:首先根节点以及其左右子树, ...
- 框架:Flutter(移动应用程序开发框架)
ylbtech-框架:Flutter(移动应用程序开发框架) Flutter是谷歌的移动UI框架,可以快速在iOS和Android上构建高质量的原生用户界面. Flutter可以与现有的代码一起工作. ...
- 软件-开发软件:Android Studio
ylbtech-软件-开发软件:Android Studio Android Studio 是谷歌推出的一个Android集成开发工具,基于IntelliJ IDEA. 类似 Eclipse ADT, ...
- Python学习之文件操作(二)
CSV文件处理 在Python中处理CSV文件可以使用模块csv.有关csv模块的官方资料看这里. 1 读取csv文件 csv.reader(csvfile, dialect='excel', **f ...
- COGITATE | 分析当前热门软件的创新
热门软件分析实例一——Github [简介] gitHub是一个面向开源及私有软件项目的托管平台,因为只支持git 作为唯一的版本库格式进行托管,故名gitHub.作为一个分布式的版本控制系统,在Gi ...
- 容斥原理——hdu3208
和hdu2204有点像 这题要特别注意精度问题,如pow的精度需要自己搞一下,然后最大的longlong可以设为1<<31 /* 只要求[1,n]范围内的sum即可 那么先枚举幂次k[1, ...