파이썬[Python]: 내장함수 - __ne__ 메서드
파이썬(Phthon): 내장함수 - __ne__ 메서드(method)
/// 설명
self 와 other 를 비교합니다.(self != other: True)
other 은 비교할 객체입니다.
참고: __lt__(), __le__(), __eq__(), __gt__(), __ge__()
※ 형식
object.__ne__(self, other)
reference
https://docs.python.org/3/reference/datamodel.html
other 은 비교할 객체입니다.
참고: __lt__(), __le__(), __eq__(), __gt__(), __ge__()
※ 형식
object.__ne__(self, other)
reference
https://docs.python.org/3/reference/datamodel.html
/// 예제
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | class A: def __init__(self, a): self.a = a def __ne__(self, other): return self.a != other.a print(A(1).__ne__(A(2))) # True a = A(1) b = A(2) print(a != b) # True if a != b: print('a is not equal to b') else: print('a is equal to b') # a is not equal to b | cs |
* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)
– 당신을 응원합니다. –
댓글
댓글 쓰기