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中避免创建全局变量一是避免命名冲突,二是避免因为创建全局变量让代码变得脆弱,三是创建全局变量会让代码难以测试. 二.避免创建全局变量的几种方法 //避免全局变量 避免命名冲 ...
随机推荐
- Sqlite多线程相关整理
Sqlite多线程相关整理 Sqlite With MultiThreads 什么是线程安全? 当多个线程访问某个方法时,不管你通过怎样的调用方式.或者说这些线程如何交替地执行,我们在主程序中不需要去 ...
- datetime模块练习
#_author:来童星#date:2019/12/6#1.获取当前日期import datetimeprint(datetime.date.today())# 2019-12-06#2.使用toda ...
- mySql搜索引擎
转载自 深入浅出mysql数据库 MySQL5.5以后默认使用InnoDB存储引擎,其中InnoDB和BDB提供事务安全表,其它存储引擎都是非事务安全表. 若要修改默认引擎,可以修改配置文件中的def ...
- 重磅发布: 阿里云WAF日志实时分析上线 (含视频)
摘要: 阿里云WAF与日志服务打通,对外开发Web访问与攻击日志.提供近实时的网站具体的日志自动采集存储.并提供基于日志服务的查询分析.报表报警.下游计算对接与投递的能力. 背景 Web攻击形势 互联 ...
- duilib教程之duilib入门简明教程13.复杂控件介绍
首先将本节要介绍的控件全部拖到界面上,并调整好位置,如图: 然后将Name属性改成其他名字, 不能是[控件名+UI+数字]这种,因为这是DuiDesigner默认的名字,它不会实际写 ...
- idea社区版+第一个spring boot项目+增删改查+yml修改端口号
参考:https://www.cnblogs.com/tanlei-sxs/p/9855071.html 中途出现问题时参考了太多 1.下载idea社区版 2.在settings -> Plug ...
- PAT甲级——A1126 Eulerian Path【30】
In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similar ...
- 《DSP using MATLAB》Problem 8.38
代码: function [wpLP, wsLP, alpha] = bp2lpfre(wpbp, wsbp) % Band-edge frequency conversion from bandpa ...
- Netstat- Linux必学的60个命令
1.作用 检查整个Linux网络状态. 2.格式 netstat [-acCeFghilMnNoprstuvVwx][-A][--ip] 3.主要参数 -a--all:显示所有连线中的Socket. ...
- java char <-> int
int = char - '0' or Character.getNumericValue(char ch) char = (char)int