def buy(self, index):
        """ Attempts to buy indexed item, returns result
           
        Parameters:
           index (int) -- The item index
           
        Returns
           bool - True if item was bought, false otherwise
        """
        item = self.items[index]
        us = UserShopFront(self.usr, item.owner, item.id, str(item.price))
        us.load()
        
        if not item.name in us.inventory:
            return False
        
        if not us.inventory[item.name].buy():
            return False
                
        return True
def buy ( self , index ) : item = self . items [ index ] us = UserShopFront ( self . usr , item . owner , item . id , str ( item . price ) ) us . load ( ) if not item . name in us . inventory : return False if not us . inventory [ item . name ] . buy ( ) : return False return True
Attempts to buy indexed item, returns result
           
        Parameters:
           index (int) -- The item index
           
        Returns
           bool - True if item was bought, false otherwise