to property or function in class object
james_027
cai.haibin at gmail.com
Thu Aug 16 22:29:47 EDT 2007
hi,
i am very new to python, not knowing much about good design. I have an
object here for example a Customer object, where I need to retrieve a
info which has a number of lines of code to get it.
my question is weather what approach should I use? to use the property
which is from the python new class style as I understand or simple use
function that will return the the info I needed.
class Customer(object):
current_balance = property(fget=_get_current_balance)
def _get_current_balance(self):
# coding here
or
def get_current_balance(self):
# coding here
While both approach would get the job done, I don't know much about
the performance, benefits, design philosophy between the two approach.
Any lecture will be very appreciated.
Thanks
james
More information about the Python-list
mailing list