Looking for OOP Pythonic approach for putting objects in a 'list object' as opposed to just using [list]
Question: For some reason I cannot conceptualize how to use Checkbook.class object
instead of "ledger [list]" Trying to keep my approach OOP. What is a best
practices approach to the objectives of this code? (Yes, I have other "newbie"
questions too, but I would be happy just to get some input on this.)

    
    
    import sys
    import time
    
    transNum=0
    ledger = []
    debitInput=['Check Number: ', 'Transaction Date: ',
                'Payee: ', 'Amount: ', 'Memo (or Enter to skip): ']
    creditInput=['Check Number: ', 'Transaction Date: ',
                'Source: ', 'Amount: ', 'Memo (or Enter to skip): ']
    
    # a Payee is a persistent record/lookup of current, past and new payees
    class Payee:
        pass
    
    # a Source is a persistent record/lookup of current, past and new sources
    class Source:
        pass
    
    
    # a Checkbook is a collection of Transaction objects upon which queries may be performed
    class Checkbook:
        def __init__(self, newTrans):
            pass
    
    # a Transaction is a collection of Debit and Credit objects
    class Transaction:
        def __init__(self, chkNum, transDate, thirdParty, amount, memo=''):
            self.chkNum = chkNum
            self.transDate = transDate
            self.memo=memo
            self.thirdParty=thirdParty
            self.amount=amount
            self.transNum = transNum
    
    
    
    class Debit(Transaction):
        def __init__(self, *args):
            Transaction.__init__(self, *args)
            self.payee=self.thirdParty
            del self.thirdParty
            self.amount=int(self.amount)*-1
    
    
    class Credit(Transaction):
        def __init__(self, *args):
            Transaction.__init__(self, *args)
            self.source=self.thirdParty
            del self.thirdParty
            self.amount=int(self.amount)
    
    
    while True:
        transact = []
        transNum += 1
        choice=input('Posting debit [d], credit [c] or [x] to exit: ')
        if choice == 'x': break
        elif choice == 'd':
            for field in debitInput:
                field = input(field)
                transact.append(field)
            trans = Debit(transact[0], transact[1], transact[2], transact[3], transact[4])
            ledger.append(trans)
    
    
        elif choice == 'c':
            for field in creditInput:
                field = input(field)
                transact.append(field)
            trans = Credit(transact[0], transact[1], transact[2], transact[3], transact[4])
    


Answer: 
    class Checkbook:
    
        def __init__(self):
            self.transactions = []    # Checkbook is just a wrapper around a list
    
        def __getitem__(self, index): # implementing [x]
            return self.transactions[index]
    
        def __setitem__(self, index, transaction): #implementing [x] = i
            self.transactions[index] = transaction
    
        def append(self, transaction): # implementing .append(x)
            self.transactions.append(transaction)
    
        def extend(self, transaction_list): # implementing .extend([x,y,z])
            self.transactions.extend(transaction_list)
    
        # and so on for every method which you want to support
    

Or you can [subclass `list`](http://stackoverflow.com/questions/8180014/how-
to-subclass-python-list-without-type-problems).

Is this for homework? It's silly to assign this in Python. [You'd never really
want to subclass `list`](http://stackoverflow.com/questions/8180014/how-to-
subclass-python-list-without-type-problems#comment10047774_8180014). I had a
better exercise in university in which I had to re-implement a `std::vector`
using templates, a dynamic array (with `malloc()`), and operator
overloading... what fun! The `std::map` exercise was even better :)

