Python 2.7 ( r27 :82508, Jul 3 2010, 21:12:11)
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
import dicom
u = dicom.UID.UID('1.2.840.10008.1.2.4.50')
u
'1.2.840.10008.1.2.4.50'
u == 3
True
u == None
True
This is due to how the UID.eq function uses str.eq:
Using str(u) == None gives the expected answer of False. I think that using 'is True' in the comparison function will work:
def __eq__(self, other):
"""Override string equality so either name or UID number match passes"""
if str.__eq__(self, other) is True:
return True
if str.__eq__(self.name, other) is True:
return True
return False
That could be shortened to:
return str.__eq__(self, other) is True or str.__eq__(self.name, other) is True
I'm not 100% certain that either of those handle all cases, though.
From wickedg...@gmail.com on January 14, 2011 20:48:04
Python 2.7 ( r27 :82508, Jul 3 2010, 21:12:11) [GCC 4.0.1 (Apple Inc. build 5493)] on darwin Type "help", "copyright", "credits" or "license" for more information.
This is due to how the UID.eq function uses str.eq:
Using str(u) == None gives the expected answer of False. I think that using 'is True' in the comparison function will work:
That could be shortened to:
I'm not 100% certain that either of those handle all cases, though.
Original issue: http://code.google.com/p/pydicom/issues/detail?id=96