GateNLP / gate-lf-pytorch-json

PyTorch wrapper for the LearningFramework GATE plugin
Apache License 2.0
1 stars 2 forks source link

Figure out the difference between importing a user module in python 3.5 vs. 3.6 #23

Closed johann-petrak closed 6 years ago

johann-petrak commented 6 years ago
# the following fails works in python 3.6 and fails in python 3.5.2
parent=importlib.import_module(".."+ptclassname,package=".gatelfpytorchjson.modules."+ptclassname)
# this works fine:
parent = importlib.import_module("gatelfpytorchjson.modules."+ptclassname)

in both cases we need to then use

class_ = getattr(parent, ptclassname)
johann-petrak commented 6 years ago

OK, on one computer, parent = importlib.import_module("gatelfpytorchjson.modules."+ptclassname) works for both python 3.5 and 3.6, lets go with this for now.