#!/usr/bin/env python3
# OS: Ubuntu 10.4LTS

# My code:

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 show(self):
        return ("ACNT: {}  ${:0.2f} {}".
            format(self.account, self.amount, self.debit_or_credit))

    def get_line_item(text):
        return JournalLineItem(*text.split())

def test():
    print(
    JournalLineItem.get_line_item("2435 Dr 25.33").show())

if __name__ == "__main__":
    test()

    myquestion = """
What kind of a method/function is get_line_item?
From what I've read (and not fully understood)
static methods and class methods must have
@staticmethod and @classmethod on the line above them.
get_line_item works as I wanted but it's clearly not the
usual type of method and I don't know how to categorize it.
It's an instance creator- is there a better term?
Is this 'Pythonic' code?
"""
    as_always = """Thanks,

    Alex Kleider"""
~
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to