-
Book Overview & Buying
-
Table Of Contents
Metaprogramming with Python
By :
In this section, let’s create an even more customized data type to deal with the dress size of the fashion department of ABC Megamart. The DressSize data type we defined in the preceding section handles any integer as input and performs the operations we overloaded. When we look at the domain of the fashion industry and consider the dress size as a domain-specific variable, the DressSize data type should ideally be considering only specific values for size and not accept all integers. The dress size will be based on the size of dresses held in the inventory of ABC Megamart.
The accepted input for dress size in this example should be the list of integers, [36,38,40,42,44,46,48], or the list of strings that indicates the equivalent text values for dress size such as [XS,S,M,L,XL,XXL,XXXL]:
DressSize class along with its methods to work as a domain-specific data type, and initialize size as its...