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. thinkphp 多层mvc

    hinkPHP基于MVC(Model-View-Controller,模型-视图-控制器)模式,并且均支持多层(multi-Layer)设计. 模型(Model)层 默认的模型层由Model类构成,但 ...

  2. tornado接收ajax的post请求报错WARNING:tornado.access:405 OPTIONS /add

    后端报错信息 WARNING:tornado.access:405 OPTIONS /add (::1) 1.00m 前端报错信息 2xhr.js?ec6c:172 OPTIONS http://lo ...

  3. 跨域问题The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by t

    withCredentials 属性 上面说到,CORS请求默认不发送Cookie和HTTP认证信息.如果要把Cookie发到服务器,一方面要服务器同意,指定Access-Control-Allow- ...

  4. Excel VBA 连接各种数据库(三) VBA连接SQL Server数据库

    本文主要涉及: VBA中的SQL Server环境配置 VBA连接SQL Server数据库 VBA读写SQL Server数据 如何安装SQL Client 系统环境: Windows 7 64bi ...

  5. laravel装饰者模式例子

    interface Decorator{ public function display(); } class XiaoFang implements Decorator { private $nam ...

  6. USART 串口

    串口不工作 请逐一检查: 是否正确配置复用IO口(先用RCC_APB2PeriphClockCmd在RCC寄存器中先开启GPIOx的时钟使能,再用 GPIO_Init 进行IO复用配置) 是否正确配置 ...

  7. 基于token的验证

    认证.权限和限制 身份验证是将传入请求与一组标识凭据(例如请求来自的用户或其签名的令牌)相关联的机制.然后 权限 和 限制 组件决定是否拒绝这个请求. 简单来说就是: 认证确定了你是谁 权限确定你能不 ...

  8. [WPF自定义控件]?Window(窗体)的UI元素及行为

    原文:[WPF自定义控件]?Window(窗体)的UI元素及行为 1. 前言 本来打算写一篇<自定义Window>的文章,但写着写着发觉内容太多,所以还是把使用WindowChrome自定 ...

  9. uoj349 即时战略

    题意:这是一道交互题.交互库中有一棵树.一开始只有1节点已知.需要在T次询问内使得n个节点都已知.一次询问explore(x,y),返回从x到y路径上第一个点,并将返回点标记为已知. 数据有区分. 标 ...

  10. bzoj2209 括号序列

    题意:给你一个括号序列.操作1:询问需要更改多少个括号使之匹配. 操作2:反转序列,左括号变成右括号. 操作3:翻转序列,倒置. 标程: #include<cstdio> #include ...