Reputation: 179
I have a the following file in Python:
SB/__init__.py
from .interval import *
SB/interval.py
class Interval:
blablabla # Do stuff with intervals
def __eq__(self, other):
# Do comparison
def __lt__(self, other):
# Do comparison
def __le__(self, other):
# Do comparison
def __gt__(self, other):
# Do comparison
def __ge__(self, other):
# Do comparison
def interval_from_file(filename):
blablabla # Read the file, etc
result = []
for l in lines:
fields = l.split('\t')
... # Validate the fields
result.append(Interval(fields))
return result
If I do import SB
from an IPython shell or Jupyter and I load some data with SB.interval_from_file
, I get a list of Interval objects. But, if I then manually create an Interval object with SB.Interval
, I cannot compare that object with any other from the list. I get instead
TypeError: '<' not supported between instances of 'Interval' and 'Interval'
Any idea what's going on?
edit: If I print the type of the objects, the ones in the list (so from SB.interval_from_file
have the type SB.interval.Interval
whereas the object created in the IPython shell with SB.Interval
is of type interval.Interval
. Is that behavior expected?
Upvotes: 2
Views: 65
Reputation: 26904
Maybe your pythonpath is including both SB and its parent directory.
Make sure you include just the appropriate directory.
Upvotes: 1