2009-09-18 18 views

回答

4

这些例子没有问题。只需使用complextype。你只是在一个非常有限的范围内(类定义本身)。在那之后,你会使用点符号(self.type)来访问它们,所以没有歧义:

Python 2.6.2 (release26-maint, Apr 19 2009, 01:58:18) 
[GCC 4.3.3] on linux2 
Type "help", "copyright", "credits" or "license" for more information. 
>>> class Foo(object): 
...  type = 'abc' 
... 
>>> f = Foo() 
>>> f.type 
'abc' 
>>> class Bar(object): 
...  complex = 123+4j 
... 
>>> bar = Bar() 
>>> bar.complex 
(123+4j) 
>>> 
+1

从技术上说,你给的例子并不保留字。他们是内置的。保留字(如print或lambda)会导致实际问题。 – jcdyer 2009-09-18 18:23:41

1

你真的想使用db_column="complex"的参数,并调用你的领域别的东西吗?

相关问题