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的更多相关文章

  1. 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 ...

  2. 设计模式之美:Extension Object(扩展对象)

    索引 意图 结构 参与者 适用性 效果 相关模式 实现 实现方式(一):使用示例结构实现 Extension Object. 实现方式(二):使用泛型实现 IExtensibleObject<T ...

  3. Group Policy Object Editor

    Group Policy Object Editor   The Group Policy Object Editor is a tool that hosts MMC extension snap- ...

  4. [No000074]C#创建桌面快捷方式

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...

  5. JavaScript Patterns 5.4 Module Pattern

    MYAPP.namespace('MYAPP.utilities.array'); MYAPP.utilities.array = (function () { // dependencies var ...

  6. Python 之作用域和名字空间

    作用域与名字空间 Python有一个核心概念是名字空间(namespace),namespace是一个name到object 的映射关系,Python有很多namespace,因此,在代码中如果碰到一 ...

  7. 白话学习MVC(五)Controller的激活

    一.概述 在此系列开篇的时候介绍了MVC的生命周期 , 对于请求的处理,都是将相应的类的方法注册到HttpApplication事件中,通过事件的依次执行从而完成对请求的处理.对于MVC来说,请求是先 ...

  8. Log4Net写入到数据库配置过程中的一些小问题备忘

    问题1: 在公司进行log4net写入服务器配置的时候,一切正常,但是在家里的机器上,就频繁出现这个问题: SQL Server 2008 报错:已成功与服务器建立连接,但是在登录前的握手期间发生错误 ...

  9. <<编写可维护的JavaScript>>之避免使用全局变量

    一.避免全局变量的理由 js中避免创建全局变量一是避免命名冲突,二是避免因为创建全局变量让代码变得脆弱,三是创建全局变量会让代码难以测试. 二.避免创建全局变量的几种方法 //避免全局变量 避免命名冲 ...

随机推荐

  1. JQuery Ajax 向后台传参方式

    在jquery的ajax函数中,可以传入3种类型的数据 文本:"uname=alice&mobileIpt=110&birthday=1983-05-12" jso ...

  2. iserver中的服务数据迁移

    今天需要将iserver测试服务器上的空间数据服务(数据源是Oracle Plus)迁移到客户的正式服务器,原想需要很大的工作量,其实是这样简单: 一.保证客户的iserver环境都已安装正确.对于o ...

  3. 基于UDP协议的套接字编程

    基于udp协议的套接字编程 UDP是无链接的,先启动那一端都不会报错 UDP协议是数据报协议,发空的时候也会自带报头,因此客户端输入空,服务端也能收到 一般不用与传输大数据 虽然没有粘包问题,但是不能 ...

  4. python笔记三

    # 数据读写不一定是文件,也可以在内存中读写 # StringIO就是在内存中读写str from io import StringIO f = StringIO() # 要把str写入StringI ...

  5. element table初始化默认选中以及切换页码的时候保留选中状态

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <!-- impor ...

  6. sql 查询问题

    在做数据导出时候,当某个表某字段含有单引号时候老是报错,所以要排除这种情况: sql查询某表某字段值带单引号情况 select 主键码 from 馆藏书目库 where 题名 like '%''%' ...

  7. 第八篇:ZTree操作总结

    花了一个多星期,终于完成了这个完整的功能,今天周五是时候总结下加深理解了. 项目要实现的功能:将树形目录发布到发布库,若是根目录,没有发布,连同自己和下面所有的子目录们全部发布:不是根目录,判断父目录 ...

  8. Activiti业务键(businessKey)

    问题:如何让业务对象和对应的流程 关联? 发现ProcessInstance 有个方法getBusinessKey()可以得到一个businessKey. ProcessInstance 对应数据库中 ...

  9. CSRF spring mvc 跨站请求伪造防御(转)

    CSRF CSRF(Cross-site request forgery跨站请求伪造,也被称为“One Click Attack”或者Session Riding,通常缩写为CSRF或者XSRF,是一 ...

  10. /bin /usr/bin /sbin /usr/sbin 目录的作用

    /bin是系统的一些指令.bin为binary的简写主要放置一些系统的必备执行档例如:cat.cp.chmod df.dmesg.gzip.kill.ls.mkdir.more.mount.rm.su ...