MobleyLab / alchemical-analysis

An open tool implementing some recommended practices for analyzing alchemical free energy calculations
MIT License
120 stars 60 forks source link

Make py3 compatible #94

Open davidlmobley opened 7 years ago

davidlmobley commented 7 years ago

Needs to be made py3 compatible

nathanmlim commented 7 years ago

I've had a converted py3 version by using anaconda's 2to3 conversion tool. There were some hiccups during conversion involving bytes/strings but I think I've handled them. Also, I've only tested this for the gromacs parser and have not tested for python2 backwards compatibility.

Just pushed the branch now

davidlmobley commented 7 years ago

Thanks, @limn1 . That works for me under python3.5 but not python2.7; it seems to be using some python3-specific features of the print function. It should, however, be possible to modify it so it can work under both. I'll have to revisit this to achieve that.

davidlmobley commented 7 years ago

e.g. print() can be python2 compatible, but I'm getting this error:

print(str1, end=' ')
                   ^
SyntaxError: invalid syntax

around line 753

halx commented 7 years ago

For compatibility with Python3 the very first import in Python 2.7 should be

from __future__ import print_function

which is ignored in Python3.

I suggest though to replace all prints with logger functions. But I guess this can be delayed until we start writing the new version.