๐ [Python] Ellipsis(โฆ) vs pass
Ellipsis?
ํ์ด์ฌ ์ฝ๋๋ฅผ ์ฝ๋ค๋ณด๋ฉด ...
์ผ๋ก ํ ์น๋ ์ฝ๋๊ฐ ์์ฃผ ๋ณด์ธ๋ค.
์ต๊ทผ์๋ Django์ CommonMiddleware
ํด๋์ค์์ ํ์ธํ ์ ์์๋ค.
Django์ CommonMiddleware
from typing import Any
from django.http.request import HttpRequest
from django.http.response import HttpResponseBase, HttpResponsePermanentRedirect
from django.utils.deprecation import MiddlewareMixin
class CommonMiddleware(MiddlewareMixin):
response_redirect_class: Any = ...
def process_request(
self, request: HttpRequest
) -> HttpResponsePermanentRedirect | None: ...
def should_redirect_with_slash(self, request: HttpRequest) -> bool: ...
def get_full_path_with_slash(self, request: HttpRequest) -> str: ...
def process_response(
self, request: HttpRequest, response: HttpResponseBase
) -> HttpResponseBase: ...
class BrokenLinkEmailsMiddleware(MiddlewareMixin):
def process_response(
self, request: HttpRequest, response: HttpResponseBase
) -> HttpResponseBase: ...
def is_internal_request(self, domain: str, referer: str) -> bool: ...
def is_ignorable_request(
self, request: HttpRequest, uri: str, domain: str, referer: str
) -> bool: ...
...
๊ฐ ๊ฐ๋ ์๋ฏธ๊ฐ ๋ฌด์์ผ๊น ๊ถ๊ธํ๋ค.
์ด ...
์ Ellipsis
๋ผ๊ณ ํ๋ ํ์ด์ฌ ๊ธฐํธ์๊ณ , ์ฌ์ ์ ์ผ๋ก๋ ์๋ต
, ์๋ต๋ถํธ
๋ผ๋ ์๋ฏธ๋ฅผ ๊ฐ๊ณ ์๋ค.
ํ์ด์ฌ ๊ณต์ ๋ฌธ์์์ ํ์ธํ ์ ์์๋ค.
๊ฒฐ๊ตญ ์๋ฌด ๋์๋ ํ์ง ์๋ ๊ฒ์ด๋ฏ๋ก, pass
์ฒ๋ผ ์ฌ์ฉํ ์๋ ์๋ ๊ฒ์ด์๋ค.
์ผ๋จ ๋ง๋ค๊ณ ๋ด๋ถ ๊ตฌํ์ ๋์ค์ ์์ธํ ํ๊ฒ ๋ค๋ ์๋ฏธ๋ก..!
pass?
pass
๋ํ Ellipsis
์ฒ๋ผ ์๋ฌด ๋์์ ์ํํ์ง ์๋๋ค๋ ๊ฒ์ ์๋ฏธํ๋ค.
์ผ๋ถ ์ฝ๋๊ฐ ๊ตฌ๋ฌธ ์ ํ์๋ ํ์ง๋ง ํ๋ก๊ทธ๋จ์ด ์๋ฌด ์์ ๋ ํ์ง ์๊ธฐ๋ฅผ ์ํ๋ ๊ฒฝ์ฐ์ ์ฌ์ฉํ๋ค.
์ด๋ ๊ฒ ๋งํ๋ฉด ์ด๋ค ๊ฒฝ์ฐ์ ์ฌ์ฉํด์ผํ๋ ๊ฒ์ธ์ง ์๋ฟ์ง๋ ์๋๋ฐ, ์ถ์ํด๋์ค
ํน์ ๋ฐ๋ณต๋ฌธ์์์ ๊ฒฝ์ฐ๋ฅผ ์๊ฐํ๋ฉด ๋ ๊ฒ ๊ฐ๋ค.
๋๊ธ๋จ๊ธฐ๊ธฐ