On 03/08/16 18:58, Justin Korn via Tutor wrote: > This is what I have so far:
OK, This is starting to look a bit random. You need to slow down and work through what is happening in each method and especially what data is being passed around where. At the moment it makes no sense whatsoever. > def load_file(): > with open("warehouse_data.txt") as infile: > for line in infile: > data = process_line(line) Where is process_line defined? And what happens to data? At the moment its a local variable that disappears when load_file terminates. > class Order(): > def __init__(self, order_number): > self.order_number = order_number > > def add_item(): > order = [] > order.append() What do you think this does? It takes no input values and appends nothing(*) to a list that is deleted at the end of the function. I'm pretty certain that's not what you want. (*) In fact append will error because it needs an input value. > def sort_key(): > all_keys = [] > for item in self.order_number: > all_keys.append(item.sort_key()) > return min(all_keys) You are looping over self.order_number. What kind of data is order_number? What kind of data will item be? Does item have a sort_key() method? Also neither function has a self parameter so will not be usable methods of the class. > class LineItem(): > def __init__(self, orderNumber, partNumber, quantityNumber, aisleNumber, > shelfNumber, binNumber): > self.orderNumber = orderNumber > self.partNumber = partNumber > self.quantityNumber = quantityNumber > self.aisleNumber = aisleNumber > self.shelfNumber = shelfNumber > self.binNumber = binNumber > > def sort_key(): > p = (self.aisleNumber, self.shelfNumber, self.binNumber) > for i in p: > p.sort(i.sort_key()) > return(self.aisleNumber, self.shelfNumber * -1, self.binNumber) Look at what the loop is doing. It iterates over three values and tries to sort the tuple p based on a sort_key method of each value. But do those values have a sort_key() method?. And does sorting p achieve anything? I assume you didn't try running this code since it would result in errors. You need to sort out the data types and use them consistently. -- 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