본문 바로가기

전체 글37

임시 비밀번호, 랜덤 문자열 generator import randomdef temporary_password_generator() -> str: """임시 비밀번호 발급 함수 참고사항: 소문자 & 대문자 & 숫자 & 특수문자(!@#$%&*?) 중 임의의 8자리 Returns: temp password """ lower_case = 'abcdefghijklmnopqrstuvwxyz' upper_case = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' number = '0123456789' symbols = '!@#$%&*?' USE_FOR = lower_case + upper_case + number + symbols length_for_pass = 8 temp_password.. 2024. 5. 8.
@property와 __call__ 비교 class Calculate: def __init__(self): self.result = 3 @property def one_plus_two(self) -> int: """ 일급 객체와는 다르다. 일급 객체는 변수 할당, 함수 인자 전달, 함수의 리턴 값이 될 수 있는 특징이 있기 때문이다. """ return self.resultif __name__ == "__main__": cal = Calculate() print(cal) # print(type(cal)) # # print(cal()) # 'Calculate' object is not callable 예외 print(c.. 2024. 5. 8.
SpringDataJPA 일부 구현해보기 fetchJoin을 통해 eager loading을 사용하기 보다는 select 문에 객체들을 선언하고 명시적으로 조인을 사용하는 방식을 더 선호해서 사용하지 않지만, 깃허브에서 좋은 내용을 봐서 작성해봅니다.from typing import Generic, TypeVar, Any, Sequencefrom sqlalchemy.ext.asyncio import AsyncSessionfrom sqlalchemy import select, insertfrom .base import BaseEntityEntityType = TypeVar("EntityType", bound=BaseEntity)class BaseRepository(Generic[EntityType]): def __init__( .. 2024. 5. 5.
Python structlog Standard Library LoggingIdeally, structlog should be able to be used as a drop-in replacement for standard library’s logging by wrapping it. In other words, you should be able to replace your call to logging.getLogger() b...www.structlog.org이전 글에서 작성했던 파이썬 내장 라이브러리 logging으로 구현했던 것을 structlog로 구현할 수 있다. Python logging파이썬에서도 날짜 별로, 특정 주기마다 로그 파일을 자동으로 생성할 수 있다.(trace Id도 설정하면 좋으련만...)구글링을 하면서 정리한.. 2024. 5. 3.