On 06/01/16 04:58, Alex Kleider wrote: > class JournalLineItem(object): > def __init__(self, account, debit_or_credit, amount): > self.account = account > self.debit_or_credit = debit_or_credit > self.amount = float(amount) > ... > def get_line_item(text): > return JournalLineItem(*text.split())
> What kind of a method/function is get_line_item? As it stands its not. As its intended to be, its a named constructor. But Python doesn't support named constructors so instead it could be a class method - that is a method of the class rather than of a particular instance. But it should probably be a factory function. That is, defined at the module level and not part of the class at all. Not everything in OOP needs to be in a class. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor