A

Admin • 833K Points
Coach

Q. Which of the following will make `attr` a read-only property?

  • (A) @readonly def attr(self): return self._attr
  • (B) @property def attr(self): return self._attr
  • (C) @setter def attr(self): return self._attr
  • (D) @getter def attr(self): return self._attr
  • Correct Answer - Option(B)
  • Views: 27
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

Using `@property` allows defining read-only properties without a setter.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.