본문 바로가기

분류 전체보기408

enum-auto 출처 : https://www.pythontutorial.net/python-oop/python-enum-auto/ Python enum auto In this tutorial, you'll learn about the enum auto() function to generate unique values for enumeration members. www.pythontutorial.net Introduction to the enum auto() function 다음 예제에서는 값이 1, 2 및 3인 세 개의 멤버가 있는 열거형을 정의합니다. from enum import Enum class State(Enum): PENDING = 1 FULFILLED = 2 REJECTED = 3 이 예제에서는 열거형의 .. 2023. 4. 4.
Customize and Extend Python Enum Class 출처 :https://www.pythontutorial.net/python-oop/python-enum-class/ Customize and Extend Python Enum Class Summary: in this tutorial, you’ll learn how to customize and extend the custom Python enum classes. Customize Python enum classes Python enumerations are classes. It means that you can add methods to them, or implement the dunder methods to customize the www.pythontutorial.net Customize Python.. 2023. 4. 4.
num aliases & @enum.unique Decorator 출처 : https://www.pythontutorial.net/python-oop/python-enum-unique/ Python Enumeration Aliases & @enum.unique In this tutorial, you'll learn about enumeration aliases and how to use the enum unique decorator to ensure the uniqueness of member values. www.pythontutorial.net Introduction to the enum aliases 정의에 따라 열거형 멤버 값은 고유합니다. 그러나 동일한 값으로 다른 멤버 이름을 만들 수 있습니다. 예를 들어 다음은 Color 열거형을 정의합니다. from en.. 2023. 4. 4.
enumeration 출처 : https://www.pythontutorial.net/python-oop/python-enumeration/ Introduction to the Python Enumeration 정의에 따라 enumeration(열거형)은 고유한 상수 값을 연결한 멤버들의 집합입니다. 열거형은 종종 enum이라고 합니다. Python은 새 열거형을 정의하기 위한 Enum type을 포함하는 열거형 모듈을 제공합니다 . 또한 Enum 클래스를 서브클래싱하여 새 열거형 type을 정의합니다. 다음 예제에서는 Color라는 열거형을 만드는 방법을 보여 줍니다. from enum import Enum class Color(Enum): RED = 1 GREEN = 2 BLUE = 3 작동 방식. 1. enum 모듈에서.. 2023. 4. 4.
__slots__ Method 출처 :https://www.pythontutorial.net/python-oop/python-__slots__/ Python __slots__ In this tutorial, you will learn about the Python __slots__ and how how to use it to make your class more efficient. www.pythontutorial.net Introduction to the Python __slots__ 다음은 x 및 y 좌표를 포함하는 두 개의 특성이 있는 Point2D 클래스를 정의합니다. class Point2D: def __init__(self, x, y): self.x = x self.y = y def __repr__(self): return.. 2023. 4. 4.
overriding-method 출처 :https://www.pythontutorial.net/python-oop/python-overriding-method/ Python Overriding Methods In this tutorial, you'll learn how overriding methods work and how to override a method in the parent class from a child class. www.pythontutorial.net Introduction to Python overridding method overriding method(재정의하는 메서드)를 사용하면 sub 클래스가 parent 클래스 중 하나에서 이미 제공하는 메서드의 특정 구현을 제공할 수 있습니다. overriding me.. 2023. 4. 4.
inheritance 출처 : https://www.pythontutorial.net/python-oop/python-inheritance/ An Essential Guide To Python Inheritance By Practical Examples In this tutorial, you'll learn about Python inheritance and how to use the inheritance to reuse code from an existing class. www.pythontutorial.net Introduction to the Python inheritance 상속을 사용하면 클래스가 기존 클래스의 논리를 다시 사용할 수 있습니다. 다음과 같은 Person 클래스가 있다고 가정합니다 class Perso.. 2023. 4. 4.
delete-property 출처 : https://www.pythontutorial.net/python-oop/python-delete-property/ How to Delete a Property from an Object in Python In this tutorial, you'll learn how to use the property() class to delete the property of an object. www.pythontutorial.net Python Delete Property 클래스의 property을 만들려면 @property 데코레이터를 사용합니다. 내부적으로 @property 데코레이터는 setter, getter 및 deleter의 세 가지 메서드가 있는 property 클래스를 사용합니다. dele.. 2023. 4. 4.
readonly-property 출처 : https://www.pythontutorial.net/python-oop/python-readonly-property/ Python Readonly Property in this tutorial, you'll learn how to define Python readonly property and how to use it for computed property and caching. www.pythontutorial.net Introduction to the Python readonly property readonly property을 정의하려면 getter만 있는 속성을 만들어야 합니다. 그러나 항상 private attribute(_age)에 액세스하여 변경할 수 있으므로 진정한 읽기 전용이.. 2023. 4. 4.