LouisK130 / IFCB-Annotate

A web-based interface for classifying IFCB image data
3 stars 2 forks source link

python 3.4 compatibility #21

Closed joefutrelle closed 6 years ago

joefutrelle commented 7 years ago

For deployment purposes I would like to use Debian Jessie which ships with Python 3.4, however the following line in views.py uses a syntax that is not supported in 3.4:

result = json.dumps({**{**result1, **result2}, **result3})

can this be rewritten to not use syntactic features added after 3.4?

joefutrelle commented 7 years ago

Also in utils.py

targets = {**targets, **new_targets}

which I think is easier to fix ...

LouisK130 commented 7 years ago

Both lines should be easily made compatible with 3.4. Again, I'm not really well equipped to make any commits right now, but the required changes are pretty minimal. See link below.

https://stackoverflow.com/questions/38987/how-to-merge-two-dictionaries-in-a-single-expression

joefutrelle commented 7 years ago

In addition, there are circular imports between database and utils, which could be addressed via refactoring.

joefutrelle commented 7 years ago

Pardon my denseness, but is there a difference between

result = json.dumps({**{**result1, **result2}, **result3})

and

result = json.dumps({**result1, **result2, **result3})

?

LouisK130 commented 7 years ago

No. I think initially it was only result1 and result2 and when I added result3 I was too lazy to test if that syntax worked with more than 2 dicts.

joefutrelle commented 7 years ago

Got it, then this is an easy fix, thanks.