Movatterモバイル変換
[0]ホーム
[Python-Dev] #pragmas and method attributes
M.-A. Lemburgmal@lemburg.com
Wed, 12 Apr 2000 21:02:25 +0200
Moshe Zadka wrote:>> On Wed, 12 Apr 2000, Paul Prescod wrote:>> > About a month ago I wrote (but did not publish) a proposal that combined> > #pragmas and method attributes. The reason I combined them is that in a> > lot of cases method "attributes" are supposed to be available in the> > parse tree, before the program begins to run. Here is my rough draft.>> FWIW, I really really like this.>> def func(...):> decl {zorb: 'visible', spark: 'some grammar rule'}> pass>> Right on!>> But maybe even>> def func(...):> decl zorb='visible'> decl spark='some grammar rule'> passHmm, this is not so far away from simply letting function/methodattribute use the compiled-in names of all locals as basis, e.g.def func(x): a = 3print func.afunc.a would look up 'a' in func.func_code.co_names and returnthe corresponding value found in func.func_code.co_consts.Note that subsequent other assignments to 'a' are not recognizedby this technique, since co_consts and co_names are writtensequentially. For the same reason, writing things like 'a = 2 + 3'will break this lookup technique.This would eliminate any need for added keywords and probablyprovide the best programming comfort and the attributesare immutable per se.We would still have to come up with a way to declare theseattributes for builtin methods and modules...-- Marc-Andre Lemburg______________________________________________________________________Business:http://www.lemburg.com/Python Pages:http://www.lemburg.com/python/
[8]ページ先頭