κΈ°λ³Έμ μΌλ‘ PEP8μ μ€νμΌμ λ°λ¦ λλ€.
μΌκ΄λ μ€νμΌμ μμ±νλλ° λμμ μ£Όλ λ€μν λꡬλ€μ νμ©νκ³ μμ΅λλ€.
μμ μ¬λ¬ κ°μ§ λꡬμ€μ κ°μ₯ μ€μ¬μ΄ λλ κ²μ blackμ λλ€. blackμμ κΈ°λ³Έκ°μΌλ‘ μ§μ λ μ€μ μ λ°λ₯΄κ³ μμ΅λλ€. blackμμ λ§λ€μ΄μ£Όλ μ½λμ μ€νμΌμ μ΄κ³³μμ νμΈν μ μμ΅λλ€.
[tool.isort]
profile = "black"
max-line-length = 88
extend-ignore = E203
νμ ννΈμ νμ©μ μ½λ μμ±μ μ¬λμ 맑κΉλλ€.
def show_movie(name: str) -> None:
print("Hello " + name)
def show_movie(name: str) -> None:
if not name:
return
print("Hello " + name)
λͺ¨λ λ 벨μ λλ(__all__
, __version__
λ±)λ€μ λͺ¨λ Docstring νλ¨μ κ·Έλ¦¬κ³ μΌλ°μ μΈ λͺ¨λ μν¬νΈ μμ μμΉνλλ‘ ν©λλ€.
"""Module Docstring Sample
Blah Blah
"""
__all__ = ['A', 'B', 'C']
import sys
import os
ν΄λμ€λ₯Ό μ μν λλ μ΅μμ ν΄λμ€ object μμμ λͺ μνμ§ μκ³ μλ΅ν©λλ€.
class Movie:
pass
class Movie(object):
pass
Google Python Style Guideμ λ£°μ λ°λ¦ λλ€ .
def fetch_smalltable_rows(
table_handle: smalltable.Table,
keys: Sequence[bytes | str],
require_all_keys: bool = False,
) -> Mapping[bytes, tuple[str, ...]]:
"""Fetches rows from a Smalltable.
Retrieves rows pertaining to the given keys from the Table instance
represented by table_handle. String keys will be UTF-8 encoded.
Args:
table_handle: An open smalltable.Table instance.
keys: A sequence of strings representing the key of each table
row to fetch. String keys will be UTF-8 encoded.
require_all_keys: If True only rows with values set for all keys will be
returned.
Returns:
A dict mapping keys to the corresponding table row data
fetched. Each row is represented as a tuple of strings. For
example:
{b'Serak': ('Rigel VII', 'Preparer'),
b'Zim': ('Irk', 'Invader'),
b'Lrrr': ('Omicron Persei 8', 'Emperor')}
Returned keys are always bytes. If a key from the keys argument is
missing from the dictionary, then that row was not found in the
table (and require_all_keys must have been False).
Raises:
IOError: An error occurred accessing the smalltable.
"""
λ‘κΉ λ±μ λͺ©μ μΌλ‘ μ¬μ©λ λ, νμν κ²½μ° λ±νΈλ₯Ό νμ©ν©λλ€. λ€λ§, λ€μ κ²½μ°μ λν΄μλ μ§μ ν¬λ§·ν μ ν©λλ€.
- ꡬλΆμλ‘ λ±νΈκ° μλ κΈ°νΈλ₯Ό μ¬μ©ν΄μΌνλ κ²½μ°
- νκ°λλ μκ³Ό λ€λ₯Έ λ΄μ©μΌλ‘ headerλ₯Ό μ μ΄μΌ ν λ
logger.info(f"{name = }, {description = }")
logger.info(f"name = {name!r}, description = {description!r}")
logger.info(f"name: {name!r}, description: {description!r}") # λ±νΈ λμ μμ μ¬μ©μ΄ νμν κ²½μ°
logger.info(f"{a} + {b} = {a + b}") # μ΄λ¦μ΄ μλ μ€μ κ°μ΄ μ°μ¬μΌ ν΄μ {a + b = }λ‘ λ체ν μ μλ κ²½μ°
logger.info(f"result = {a + b}") # μ(a + b) λμ λ³λμ μ΄λ¦μ΄ νμν κ²½μ°