nanophotonics / nplab

Core functions and instrument scripts for the Nanophotonics lab experimental scripts
GNU General Public License v3.0
38 stars 15 forks source link

Inheriting from object in python 3 #87

Closed eoinell closed 4 years ago

eoinell commented 4 years ago

Using 2to3/futurize on scripts does not affect the classes inheriting from object, however this creates an issue in when running in py3. Can new-style classes in py2 implicitly inherit from object?

YagoDel commented 4 years ago

Python 2 cannot implicitly inherit from object. I think that was one of the main reasons driving the creation of Python 3 in the first place

Do you have a particular script that creates an issue? There are a few places in nplab that can lead to confusing MRO, and it might be the case we need to properly address it now that Python 3 has OO classes

eoinell commented 4 years ago

https://github.com/nanophotonics/nplab/blob/d904fc84c334a56b8d33fdacf0ca20a827196f89/nplab/instrument/__init__.py#L29 I removed object from this line in python3 as it was throwing up an MRO error. It doesn't seem to make an error when running in python2. I've been able to run Lab 6 through this branch in python2, except the data browser won't render data.

YagoDel commented 4 years ago

Are you sure you are on the right branch? already doesn't exist in the python3 branch (https://github.com/nanophotonics/nplab/blob/python3/nplab/instrument/__init__.py)

eoinell commented 4 years ago

Yeah, I removed it in python-3-from-future, and checked that it still works on py2 this morning.