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. php设置时区和strtotime转化为时间戳函数

    date_default_timezone_set('PRC');//设置中华人民共和国标准时间 strtotime — 将任何英文文本的日期时间描述解析为 Unix 时间戳 格式:int strto ...

  2. go网络库cellent实现socket聊天功能

    一 .介绍 cellnet是一个组件化.高扩展性.高性能的开源服务器网络库 git地址:https://github.com/davyxu/cellnet 主要使用领域: 游戏服务器 方便定制私有协议 ...

  3. 小程序修改默认的radio样式

    1.wxml: <radio-group class="radio-group" bindchange="radioChange"> <vie ...

  4. 自签https证书2(适配新版chrome,不会显示“不安全”)

    上一篇博文中介绍了自签https的方法,但是在新版的chrome中会出现这么一个问题:自签ca可以识别,但是证书仍然会判断不安全.为了解决这个问题,博主特地又查了好多资料,终于找到了解决方案. 当然, ...

  5. 记录一次hexo托管到coding失败,页面总是404,可是相同的代码托管到github是没问题的。

    文章目录 问题描述: 问题原因: 问题解决 2019.1.23 问题,coding又挂了. 弃疗 个人博客:https://mmmmmm.me 源码:https://github.com/dataiy ...

  6. JS 变量的数据类型 运算符

    JS中变量的类型有:数值型.字符型.布尔型.undefined.null.array.object.function 1.数值型:可以进行算术运算的(加.减.乘.除) 数值型包括:整型(整数)和浮点型 ...

  7. 第十篇:javaScript中的JSON总结

    参考网站:json中国,MDN json 一.必知基础    JSON 是JavaScript对象文字符号的一个子集,它可以自如的在JavaScript中使用.看下这个对象: var myJSONOb ...

  8. Java之RabbitMQ(一)与SpringBoot整合

    应用场景:异步处理.应用解耦.流量削峰 参照:https://blog.csdn.net/weixin_38364973/article/details/82834348 开端 RabbitAutoC ...

  9. 第二天:数值与字符串、列表list

    数值 1. 声明变量 age = 20 f = 3.14 #浮点型 f = 0.3 f = .3 2.表达式 主要是做一些简单的加减乘除运算,直接出结果 1.1 + 2.2 2.2 + 3.0 3.1 ...

  10. Stern-Brocot Tree、伪.GCD 副本

    Stern-Brocot Tree.伪.GCD 副本 伪.GCD 问题 1:\(f(a,b,c,n) = \sum_{i=0}^{n} [\frac{ai+b}{c}]\) Case 1: \(a\g ...