james_027 wrote: > 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) > This will need to go down below the definition of _get_current_balance() if you want to avoid an error in compilation.
> 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. > It's pretty much a matter of choice when the method to retrieve the value doesn't take any arguments. If it *does* take arguments then you can't use a property. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- http://mail.python.org/mailman/listinfo/python-list