mrkiven / pyzh Goto Github PK
View Code? Open in Web Editor NEW:books: 一起写Python文章,一起看Python文章 - 利用readthedocs的Python技术文章的收集和翻译。
Home Page: http://pyzh.readthedocs.org
License: BSD 2-Clause "Simplified" License
:books: 一起写Python文章,一起看Python文章 - 利用readthedocs的Python技术文章的收集和翻译。
Home Page: http://pyzh.readthedocs.org
License: BSD 2-Clause "Simplified" License
在(11.11. 创建描述符对象)中Foot类的魔法方法定义错误: __get__和__set__被错误写作了__get和__set 。
感谢诸位翻译者的无私奉献。
觉得需要分类组织一下,否则文章多了后检索很麻烦的。
https://pyzh.readthedocs.io/en/latest/index.html
浏览器提示有不安全内容,看了下是这个:
http://fonts.googleapis.com/css?family=Merriweather:400,300
完全可以改成https了
123
hi.
as3:~/pyzh/docs# make html
sphinx-build -b html -d _build/doctrees . _build/html
Making output directory...
Running Sphinx v1.2b1
loading translations [Zh_CN]... done
loading pickled environment... not yet created
Theme error:
no theme named 'rux' found (missing theme.conf?)
make: *** [html] Error 1
as3:/pyzh/docs# cd ../pyzh# find . -name theme.conf
as3:
as3:/pyzh# cd docs/pyzh/docs# find . -name theme.conf
as3:
as3:~/pyzh/docs#
原文是:
“If the looked-up value is an object defining one of the descriptor methods, then Python may override the default behavior and invoke the descriptor method instead”
感觉翻译成下面是不是更贴近愿意些:
如果找到的值是一个有描述器方法的对象。。。
9.3 注意函数的默认参数
def foo(x=[]): x.append(1); print(x)
foo(); foo()
得到:
[1]
[1, 1]
第一次调用foo() 得到x =[] ,然后x = [1],x指向列表[1]内存中的地址。
但是第二次调用foo() , x = [] 不是把x指向另一个列表[] 的地址吗?
“1.4. 描述器的调用”里面出现了一些混乱。
原文有两段:
For objects, the machinery is in object.__getattribute__() which transforms ...
For classes, the machinery is in type.__getattribute__() which transforms ...
翻译中却变为:
对于对象来讲,方法 type.__getattribute__() 把 。。。
把两段和为了一段,且中间的一部分消失了。
http://pyzh.readthedocs.org/en/latest/Descriptor-HOW-TO-Guide.html#id11
在讲述资料描述符和非资料描述符的区别的时候
资料描述器和非资料描述器的区别在于:相对于实例的字典的优先级。如果实例字典中有与描述器同名的属性,如果描述器是资料描述器,优先使用资料描述器,如果是非资料描述器,优先使用字典中的属性。
译者注:这就是为何实例 a 的方法和属性重名时,比如都叫 foo Python会在访问 a.foo 的时候优先访问实例字典中的属性,因为实例函数的实现是个非资料描述器
这里的原因应该是访问的时候属性查找顺序造成的。先查找obj.__dict__
再查找type(obj).__dict__
。属性在前一个字典里面,函数在后一个字典里面。data和no-data的主要区别根据描述可以知道仅仅用于区分属性被调用的时候是使用obj.__dict__
还是使用描述符规则。
以下例子可能比较合适
class reify(object):
def __init__(self, wrapped):
self.wrapped = wrapped
def __get__(self, inst, objtype=None):
val = self.wrapped(inst)
setattr(inst, self.wrapped.__name__, 10)
return val
# def __set__(self, instance, value):
# return
class A(object):
@reify
def a(self):
return 4
a = A()
print(a.a)
注释掉__set__
是no-data description
,调用a属性使用a.__dict__
不注释则为data description
,使用描述符规则
另外根据你的注解好像意思是实例字典是一个资料描述符而实例函数是一个非资料描述符。这里的实例字典是指代的obj.__dict__
吗?实例函数的实现我没明白指代的是什么。使用isinstance(obj.__dict__,dict)
得到True
可以看出obj.__dict__
实质就是一个dict
,是没有__get__
和__set__
属性的,因此和data-description&no-data description
没有关系
以上如有错误请指出,谢谢~~
Should be https://pyzh.readthedocs.org/en/latest/
We should set the url in conf.py
feed_base_url = "https://pyzh.readthedocs.org/en/latest/"
你觉得呢?
HTTP/1.1还引入了 块传输协议 。 它允许讲响应分解为成更小的数据块,并将它们立即发送到客户端,而不是一直等到完成HTTP请求。
这一部分重复了, 而且是它允许将相应
其实我以前想过建立这样一个网站,用户可以对网站浏览的文章的某一部分内容进行评价,标注和翻译,并且可以被其他用户看到,类似于django-book这种形式。然后定期对用户评注内容进行整理。这样对于每一个阅读者,同时他们也是文档编辑的参与者。
online链接不能打开
DNS查询结果直接为空了
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.