파이썬[Python]: 내장함수 - __ge__ 메서드

파이썬(Phthon): 내장함수 - __ge__ 메서드(method)


/// 설명

self 와 other 를 비교합니다.(self >= other: True)
other 은 비교할 객체입니다.

참고: __lt__(), __le__(), __eq__(), __ne__(), __gt__()

※ 형식
object.__ge__(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 __ge__(self, other):
        return self.a >= other.a
 
 
print(A(1).__ge__(A(2)))  # False
 
= A(1)
= A(2)
 
print(a >= b)  # False
 
if a >= b:
    print('a is greater than or equal to b')
else:
    print('a is less than b')
# a is less than b
 
cs

* 실행환경: Microsoft Windows 10 Homes
* 인터프리터: 파이썬(Python 3.9)


– 당신을 응원합니다. –

댓글

이 블로그의 인기 게시물

파이썬[Python]: 내장함수 - from_bytes 메서드

파이썬[Python]: 내장함수 - __len__ 메서드

파이썬[Python]: kivy - 한글 사용

C 언어: sin 함수, cos 함수, tan 함수

파이썬[Python]: 내장함수 - bit_length 메서드