I have type of object called "GenomicLocation". I want to support the operation "in" for that object, so that I can write
genomic_location1 in genomic_location2
if certain conditions are met.
Is this possible? If so, how do I do it?
I have type of object called "GenomicLocation". I want to support the operation "in" for that object, so that I can write
genomic_location1 in genomic_location2
if certain conditions are met.
Is this possible? If so, how do I do it?
You should define the method
__contains__
Example:
>>> class Thing(object):
... def __contains__(self, x):
... return x == 'potato'
...
>>> t = Thing()
>>> 'potato' in t
True
>>> 'spam' in t
False