Virtual Environment

python3 -m venv /Users/jaeyeolee/PycharmProjects/airflowProject/venv
source venv/bin/activate
deactivate

which python3, which pip3

pip3 list
pip3 uninstall -r requirements.txt -y : 전체 pip3 list삭제
pip3 show apache-airflow  :  how what packages are required for the specified package

pip3 freeze > requirements.txt
pip3 install -r "requirements.txt"

Python Docstrings

Untitled

Untitled

Google Style

def count_letter(content, letter):
  """Count the number of times `letter` appears in `content`.

  Args:
    content (str): The string to search.
    letter (str): The letter to search for.

  Returns:
    int 

  Raises:
    ValueError: If `letter` is not a one-character string.
  """
  if (not isinstance(letter, str)) or len(letter) != 1:
    raise ValueError('`letter` must be a single character string.')
  return len([char for char in content if char == letter])

힌트 : dir(inspect) 해서 inspect module에 어떤 함수들이 있는지 봄

inspect.getdoc(count_letter)

dir(CoreModel)

['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__',
'__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__',
'__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__',
'__sizeof__', '__str__', '__subclasshook__', '__weakref__',
'find_by_cond', 'find_by_userid', 'find_many_by_userid']

count_letter.doc 하면 위에 DocString 출력됨

import builtins dir(builtins)

Pass by Assignment

Untitled

Lists in Python are mutable objects, meaning that they can be changed.

Integers in Python are immutable, meaning they can't be changed.