오늘은 파이썬의 중요한 개념인 데이터 모델(Data Model)에 대해 정리해보겠습니다. "Fluent Python"이라는 책을 읽으면서 배운 내용인데, 개인적으로는 파이썬이 내부적으로 어떻게 동작하는지 이해하는 데 정말 도움이 되었습니다. 파이썬 데이터 모델? 그것이 무엇인가? 파이썬 데이터 모델은 쉽게 말해서 파이썬이라는 언어가 '동작하는 규칙' 같은 것입니다. 우리가 리스트 길이를 잴 때 len(my_list)를 쓰거나, 특정 항목에 접근...
Have you ever wondered how Python makes objects work with operators like + or -? Or how it knows how to display objects when you print them? The answer lies in Python's magic methods, also known as dunder (double under) methods. Magic methods are spe...
This write up deals with exploring the object creation aspect in Python. Specifically, it attempts to answer following queries: How are Python objects created? How can we change that for special use cases? What magic takes place in this process? W...
Understanding Magic Methods in Python Magic methods in Python, also known as dunder methods (because they have double underscores at the beginning and end of their names), allow us to define the behavior of our objects for various operations. They en...
Imagine you've built this cool bit of logic that relies on using a Set of objects. You've written the class yourself, and now you're passing objects into a set like so. class CleverClass: def __init__(self, name: str, data: dict[str, bool]) -> No...