命名空间中的名称怎么可以是未定义的Python?

时间:2015-08-09 06:35:27

标签: python neo4j neomodel

在尝试关注http://neomodel.readthedocs.org/en/latest/getting_started.html#connecting

时,我有一个可笑的错误

我刚刚从这个环境中卸载了neo4django,因为它的名字是StringProperty,我正在尝试为neo4j创建一个类:

In [8]: from neomodel import StringProperty as SP

In [9]: class Person(StructuredNode):
   ...:     name = SP()
   ...:     
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
/home/cchilders/.local/virtualenv/another_neo4django_attempt/local/lib/python2.7/site-packages/django/core/management/commands/shell.pyc in <module>()
----> 1 class Person(StructuredNode):
      2     name = SP()
      3 

/home/cchilders/.local/virtualenv/another_neo4django_attempt/local/lib/python2.7/site-packages/django/core/management/commands/shell.pyc in Person()
      1 class Person(StructuredNode):
----> 2     name = SP()
      3 

NameError: name 'SP' is not defined

In [10]: S
%%SVG           StopIteration   SyntaxError     SystemExit
SP              StringProperty  SyntaxWarning   
StandardError   StructuredNode  SystemError 

如您所见,自动填充证明了名称就在那里。这个neomodel是特定的还是存在一个普遍的Python原因,存在的名称是未定义的?谢谢

1 个答案:

答案 0 :(得分:3)

Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> from neomodel import StringProperty as SP
>>> from neomodel import (StructuredNode, IntegerProperty,
    RelationshipTo, RelationshipFrom)
>>> 
>>> class Person(StructuredNode):
    name = SP()