python 예제중에 이상한 if문?

semjase의 이미지

아래의 코드는 인터넷에 무료로 공개되어있는 파이썬강좌 예제 입니다.
for문 바로 위에 있는
multiple = 1024 if a_kilobyte_is_1024_bytes else 1000
이게 뭔가요? 이런 if문은 처음보는데요

SUFFIXES = {1000: ['KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],
            1024: ['KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']}
 
def approximate_size(size, a_kilobyte_is_1024_bytes=True):
    '''Convert a file size to human-readable form.
 
    Keyword arguments:
    size -- file size in bytes
    a_kilobyte_is_1024_bytes -- if True (default), use multiples of 1024
                                if False, use multiples of 1000
 
    Returns: string
    '''
    if size < 0:
        raise ValueError('number must be non-negative')
 
    multiple = 1024 if a_kilobyte_is_1024_bytes else 1000
    for suffix in SUFFIXES[multiple]:
        size /= multiple
        if size < multiple:
            return '{0:.1f} {1}'.format(size, suffix)
 
    raise ValueError('number too large')
 
if __name__ == '__main__':
    print(approximate_size(1000000000000, False))
    print(approximate_size(1000000000000))
peecky의 이미지

'python 삼항연산자'로 검색해보세요.

semjase의 이미지

감사합니다

.