On Fri, Dec 12, 2014 at 8:33 AM, Ben Finney <ben+pyt...@benfinney.id.au> wrote: > Chris Angelico <ros...@gmail.com> writes: > >> A property should be used if what you're creating is "virtually an >> attribute". > > Methods are attributes. Are you distinguishing here between “callable > attribute” versus “non-callable attribute”?
I'm talking conceptually here. You can, for instance, have a stat object which has attribute for the file size and owner, and then it makes equal sense to have an "is_dir" attribute; but that one might be a property, calculated from the file mode. It makes logical design sense for it to be an attribute with the value right there, so it makes design sense for it to be a property. On the other hand, a string will not normally have, as an attribute, a lower-case version of itself, so it makes better sense for that to be a callable method rather than a property. Yes, properties and methods are attributes. That's a technical detail that has nothing to do with the design question of "should this be a property or a method". ChrisA -- https://mail.python.org/mailman/listinfo/python-list