zoukankan      html  css  js  c++  java
  • 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是指为了更容易阅读而设计出来的编程语言的语法

  • 相关阅读:
    涨知识| 在国内,如何顺利使用谷歌(转)
    css3网站收集
    淘宝客 新内容
    淘宝客工作计划
    淘宝客笔记
    java并发编程
    代理模式之远程代理
    动态代理
    模板方法模式
    Spring整合web开发
  • 原文地址:https://www.cnblogs.com/freshair_cnblog/p/7285349.html
Copyright © 2011-2022 走看看