[Python-Dev] PEP 557: Data Classes

Eric V. Smith eric at trueblade.com
Sat Sep 9 21:00:53 EDT 2017


On 9/9/2017 11:41 AM, Gustavo Carneiro wrote:
> Hi, it is not clear whether anything is done to total_cost:
> 
>      def total_cost(self) -> float:
> 
> Does this become a property automatically, or is it still a method 
> call?  To that end, some examples of *using* a data class, not just 
> defining one, would be helpful.
> 
> If it remains a normal method, why put it in this example at all? Makes 

Nothing is done with total_cost, it's still a method. It's meant to show 
that you can use methods in a Data Class.  Maybe I should add a method 
that has a parameter, or at least explain why that method is present in 
the example.

I'm not sure how I'd write an example showing you can you do everything 
you can with an undecorated class. I think some text explanation would 
be better.

Eric.



More information about the Python-Dev mailing list