title: Combining @dataclass and @property
body: <p>I'd like to use @dataclass to remove a lot of boiler plate, but I also like the data encapsulation offered by @property. Can I do both simultaneously?</p>
  <p>As a toy example, I have a class like</p>
  <pre><code>class Breakfast:
  
      def __init__(self, sausage: str, eggs: str = &quot;Scrambled&quot;, coffee: bool = False):
          self._sausage = sausage
          self._eggs = eggs
          self._coffee = coffee
  
      @property
      def sausage(self):
          return self._sausage
  
      @property
      def eggs(self):
          return self._eggs
  
      @property
      def coffee(self):
          return self._coffee
  
      def __repr__(self):
          ...
  
      def __eq__(self):
          ...
  </code></pre>
  <p>where I may also have setters for some of properties. What I'd like, is to write this in some form like this</p>
  <pre><code>@dataclass(property=True)
  class DataBreakfast:
      sausage: str
      eggs: str = &quot;Scrambled&quot;
      coffee: bool = False
  </code></pre>
  <p>(where, of course, my decorator argument doesn't work) that would do all the routine stuff that @dataclass does, and essentially outputs the code of the first snippet. I could then manually add setters in the rest of the class body at my leisure.</p>
  <p>This seems like a common enough use case, but I couldn't figure out a way of getting it to work. The frozen parameter is the closest to what I want, but it doesn't really behave like @property as it precludes any kind of setter.</p>