![]() |
| ||
| Pay system Its about the pay system of a shop. The user enters a product ID,the interpreter gets the details from the file and appends it to a list and continues till the products are over. If the user can't enter the ID he can add the product name directly which will get the details from the file and append to list again. From the list the total price will be displayed and the product names which will be in the file. There must also be a fucntion to delete a product from the list and make new sum accordingly. |
| ||
| Re: Pay system def ID_search(prod_id):This is the function i've used for search the ID from the file and display result..Please need help from here on. Editor's note: Please use code tags with your code to preserve the indentations. Otherwise the code is very difficult to read and not too many folks will help. [code=python] your Python code here [/code] |
| ||
| Re: Pay system Dear Feenix45, The best way is to enclose the code in bracket to maintain the Indentation which is vita important. Just wrap your code tags Is this what you originally wrote?? Is your application GUI or Console? def ID_search(prod_id): |
| ||
| Re: Pay system Also, you open the file and read the entire file for each ID entered. This is time consuming (in computer time) and so you should consider reading the file once and placing the records in a dictionary, indexed on ID, and using the dictionary to look up the info as it is entered. |
| ||
| Re: Pay system hmm its GUI but about dictionary never did this can u help me with the indexes and dictionary plz. |
| ||
| Re: Pay system Quote:
Or just tell me how to start please |
| ||
| Re: Pay system Here's an example of reading the file into a dictionary: def load_IDs(): |
| ||
| Re: Pay system Quote:
Can i work directly from the file? |
| ||
| Re: Pay system You're reading the contents of the file into a dictionary, not a list. What do you mean work directly from the file? |
| ||
| Re: Pay system Quote:
all the data are stored on a text file which im using though its a bit more time consuming. Is there a way that i can do product search?i.e i enter the product name and it displays the price. The program must search the price in the file. |
| All times are GMT -4. The time now is 8:47 am. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC