dataclass2 0903. L1: Bartender, drinks! Complete the function that receives as input a string, and produces outputs according to the following table: Input Output "Jabroni" "Patron Tequila" "School Counselor" "Anything with Alcohol" "Programmer" "Hipster Craft Beer" "Bike Gang Member" "Moonshine" "Politician" "Your tax dollars" "Rapper" "Cristal" anything else "Beer" Note: anything else is the default case: if the input to the functio.. 2022. 9. 3. Python _ dict의 keys()처럼 dataclass에서 속성 목록 가져오기 파이썬에서 객체를 만드는 방법 중에 dataclass가 있다. @dataclass 데코레이터를 사용하면 타입 유형을 명시한 객체를 만들 수 있다. dataclass를 만드는 코드는 아래와 같다. from dataclasses import dataclass @dataclass(frozen=True) class Dataclass: a:int b:int c:int data = Dataclass(a=1,b=3,c=5) print(data) # 출력 : Dataclass(a=1, b=3, c=5) print(data.a) # 1 print(data.b) # 3 print(data.c) # 5 이렇게 만든 객체는 타입 유형을 명시하고 싶을 때나 DTO, 값 객체 등의 불변 객체로도 사용할 수 있다. dataclas.. 2022. 6. 21. 이전 1 다음