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中避免创建全局变量一是避免命名冲突,二是避免因为创建全局变量让代码变得脆弱,三是创建全局变量会让代码难以测试. 二.避免创建全局变量的几种方法 //避免全局变量 避免命名冲 ...
随机推荐
- leetcode-157周赛-5216-统计元音字母序列的数目
题目描述: 方法:倒推 class Solution(object): def countVowelPermutation(self, n): MOD = 10 ** 9 + 7 a=e=i=o=u= ...
- Jupyter notebook文件默认存储路径以及更改方法
1.文件默认存储路径怎么查? 安装Anaconda后,新建文件的默认存储路径一般在C系统盘,那么路径是什么呢? 首先,新建一个.ipynb文件, 输入以下脚本,运行出的结果即是当前jupyter文件 ...
- Go语言简介以及安装
http://www.runoob.com/go/go-tutorial.html Go 是一个开源的编程语言,它能让构造简单.可靠且高效的软件变得容易. Go是从2007年末由Robert Grie ...
- R语言 包
R语言包 R语言的包是R函数,编译代码和样本数据的集合. 它们存储在R语言环境中名为"library"的目录下. 默认情况下,R语言在安装期间安装一组软件包. 随后添加更多包,当它 ...
- iServer添加Oracle Plus数据源、服务发布的问题
今天在将以Oracle Plus为数据源的工作空间发布成服务时,发现服务发布完后,看不见任何数据.最后发现,还需要在iserver服务器上安装oracle客户端才行.整理如下: 一.创建空间数据库账户 ...
- STM32 STM32F4 寄存器怎么配置不上, 无法往寄存器写入数据
当出现这个问题时,往往是因为你没有在RCC寄存器中把相关的时钟使能打开. 配置寄存器之前记得调用"RCC_AxxxPeriphClockCmd"先打开需要配置的时钟源,别调用了“R ...
- Integer 类和 int 基本数据类型的区别
public static void main(String[] args) { Integer i = 10; Integer j = 10; System.out.println(i == j); ...
- 4_7.springboot2.x嵌入式servlet容器自动配置原理
概述 Spring Boot对所支持的Servlet Web服务器实现做了建模抽象: Servlet容器类型 WebServer模型接口 WebServer工厂实现类 Tomcat Tomca ...
- USACO training course Number Triangles 数塔 /// DP oj10122
题目大意: ...就是数塔 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 7+3+8+7+5=30 ...
- (转)打开Mac OSX原生的NTFS功能
xingchongsmbp3:~ xingchong$ xingchongsmbp3:~ xingchong$ xingchongsmbp3:~ xingchong$ sudo ln -s /Volu ...