is_<whatever_you_are_testing_for> as method or property?
Ethan Furman
ethan at stoneleaf.us
Thu Dec 11 13:34:58 EST 2014
More information about the Python-list mailing list
Thu Dec 11 13:34:58 EST 2014
- Previous message (by thread): is_<whatever_you_are_testing_for> as method or property?
- Next message (by thread): Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 12/11/2014 09:34 AM, Mateusz Loskot wrote: > > def is_<whatever_you_are_testing_for>(): > pass > > like 'is_even'. > > Should I define it as a classic method > > def is_even(self): > pass > > or as a property > > @property > def is_even(self): > pass > > So, a classic method or a property, which one is the Pythonic 3 way for > such member predicates? Generally, attributes (and properties look like attributes) are for items that the object already knows the answer to, and methods are for things that need to be calculated, and may change throughout the life of the object. -- ~Ethan~ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: OpenPGP digital signature URL: <http://mail.python.org/pipermail/python-list/attachments/20141211/c2a2e23e/attachment.sig>
- Previous message (by thread): is_<whatever_you_are_testing_for> as method or property?
- Next message (by thread): Text Code(from 'Getting Started in Beautiful Soup' re: cd Soup , returns 'Syntax Error, invalid syntax'
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list