Re: [Neo4j] Does py2neo work with Python 3?

179 views
Skip to first unread message

Nigel Small

unread,
Aug 20, 2012, 4:02:54 PM8/20/12
to ne...@googlegroups.com
Hi Jim

Some time back, an old version of py2neo worked with Python 3 but I haven't kept an eye on the compatibility, partly because I wasn't aware of anyone actually requiring it. I should of course have removed the Python 3 tag - apologies for that.

I'm not actually sure how much work is involved in making it cross-version compatible again. Generally, the two approaches would be to either write code which works in both versions (fiddly and time consuming but probably the best choice) or write a separate version for Python 3 (possibly not enough interest to make it worthwhile plus a bit of a nightmare from a package publishing perspective). Is there a specific reason you've chosen Python 3.x over 2.x?

If there's enough demand, I'll happily look at re-implementing compatibility. In the meantime, I guess I ought to remove the Python 3 tag!!

Cheers
Nige


On 20 August 2012 19:48, Jim Nyffeler <jimny...@gmail.com> wrote:
Py2neo 1.3.0 in the Python Package Index says that it will work with Python 3.
I can get it to work fine with Python 2.7.3, but get numerous (correct) errors when
trying to run it under Python 3.2.2.  The code appears to me to be Python 2
syntax, not Python 3.  I have used Python for some time, but I am brand new
to neo4j and py2neo.  Is py2neo not yet ready for Python 3, or is there something
I don't understand?  I am using Windows 7 Professional.  The actual neo4j release
does not matter: I never get far enough to even try to connect to a database.

--
 
 

James Thornton

unread,
Aug 20, 2012, 5:52:39 PM8/20/12
to ne...@googlegroups.com
Hi Jim -

Bulbs (http://bulbflow.com) is compatible with Python 2.7 - Python 3.2.3.

- James

Roman

unread,
Mar 23, 2013, 11:13:38 AM3/23/13
to ne...@googlegroups.com

Hi Jim, Nigel

I got my scripts that use py2neo working with py2neo-1.4.6 and python 3.3.0.

So far, only the file neometry.py needed a 2to3 treatment:

sudo 2to3 -w neometry.py
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored neometry.py
--- neometry.py (original)
+++ neometry.py (refactored)
@@ -22,7 +22,7 @@
 """
 
 
-from util import round_robin
+from .util import round_robin
 
 
 class Path(object):
@@ -48,7 +48,7 @@
         out.append(str(self._nodes[-1]))
         return "".join(out)
 
-    def __nonzero__(self):
+    def __bool__(self):
         return bool(self._edges)
 
     def __len__(self):
RefactoringTool: Files that were modified:
RefactoringTool: neometry.py

Nigel Small

unread,
Mar 23, 2013, 2:20:30 PM3/23/13
to Neo4J
There were a couple of earlier versions of py2neo which worked with Python 3 but I had some trouble keeping one code base compatible with both 2 and 3 as time went on. I have changed my approach with newer development however and for the soon-to-be-released py2neo 1.5, I have done the vast majority of development in Python 3.3.

My aim therefore for py2neo 1.5 is to be compatible with Python versions 2.6, 2.7 and 3.3 upwards. I do not plan to support 3.0-3.2.

Hope this helps clarify.
Nigel


--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages