[Python] Underscore '_' 의 목적

1 minute read

[Python] Underscore ‘_’ 의 목적

There are 5 cases for using the underscore in Python.

  1. For storing the value of last expression in interpreter.
  2. For ignoring the specific values. (so-called “I don’t care”)
  3. To give special meanings and functions to name of vartiables or functions.
  4. To use as ‘Internationalization(i18n)’ or ‘Localization(l10n)’ functions.
  5. To separate the digits of number literal value.
  • 인터프리터(Interpreter)에서 마지막 값을 저장할 때
  • 값을 무시하고 싶을 때 (흔히 “I don’t care”라고 부른다.)
  • 변수나 함수명에 특별한 의미 또는 기능을 부여하고자 할 때
  • 국제화(Internationalization, i18n)/지역화(Localization, l10n) 함수로써 사용할 때
  • 숫자 리터럴값의 자릿수 구분을 위한 구분자로써 사용할 때