On Sep 24, 7:49 am, flebber <flebber.c...@gmail.com> wrote: > On Sep 24, 11:10 pm, flebber <flebber.c...@gmail.com> wrote: > > > > > On Sep 24, 10:58 pm, Dave Angel <da...@ieee.org> wrote: > > > > flebber.c...@gmail.com wrote: > > > > I am using python 2.6.2, I haven't updated to 3.0 yet. No I have no > > > > class or instructor, I am learning this myself. I have Hetlands book > > > > "Beginning Python Novice to Professional and online documentation > > > > books so Dive into Python, python.org etc. > > > > > Using the SPE editor. > > > > > I have currently only fully written basic psuedocode to give me a > > > > basic framework to guide myself. > > > > > #Basic pseudocode > > > > #Purpose to get raw input and calculate a score for a field of options > > > > and return that > > > > #score in a set in descending order. > > > > #Multiple sets sould be written to the doc > > > > > #Obtain date > > > > #Check if txt file with same date exists. If yes apphend to results to > > > > file. > > > > #Obtain location > > > > #Set Dictionary > > > > #Event number > > > > #Obtain set size > > > > #Prompt first entry > > > > #First Entry Number > > > > #First Entry Name > > > > #Set Blocks to obtain and calculate data > > > > #Block 1 example - Placings Block > > > > #Obtain number of events competed in > > > > #Obtain how many times finished first > > > > #Ensure this value is not greater than Number of Events > > > > #Number of Firsts divide by Events * total by 15. > > > > #Obtain Second finishes > > > > #Ensure this value is not greater than Number of Events > > > > #Number of Seconds divide by Events * total by 10. > > > > #Continue On with this > > > > #Block 2 - Lookup coach Dict and apply value. > > > > #Obtain Surname of Coach > > > > #Lookup Coach File and Match Name and get value. > > > > #Blocks continue gaining and calculating values. > > > > #create txt file named using date > > > > #Sum Values Block1 + Block2 etc > > > > #Print to file event number and field with name number individual > > > > Block totals and Sum Total > > > > #Arranged in descending Sum Total. > > > > #Prompt are there any more events? Yes return to start > > > > #Apphend all additional events to same day file seperated by blank line. > > > > How many of these steps have you attempted actually coding? Seems to me > > > your first two steps are just string manipulation, and you only need to > > > use the datetime module if you need to validate. In other words, if the > > > user specifies the date as 31/09/2009, you might want to later bounce > > > back to him with a complaint that September only has 30 days. > > > > So the first task is to accept input in the form ab/cd/efgh and > > > produce a string efgh-cd-ab.log which you will then create as a text > > > file. And if the file exists, you'll append to it instead of > > > overwriting it. Can you do that much? > > > > DaveA > > > Trying but haven't got it working, thats why I started to try and use > > datetime module. > > Surely getting it tottally mixed up > > from datetime import date > def ObtainDate(params): > date = raw_input("Type Date dd/mm/year: %2.0r%2.0r/%2.0r%2.0r/%4.0r > %4.0r%4.0r%4.0r") > print date.datetime(year-month-day) > #Check if txt file with same date exists. If yes apphend to results > to file. > date.append(datetime > > and > > def ObtainDate(params): > date = raw_input("Type Date dd/mm/year: ") > date.format = (%4.0s%4.0s%4.0s%4.0s-%2.0s%2.0s-%2.0s) > print date.format
I think you are looking for datetime.strptime() input = raw_input("Type Date dd/mm/year: ") d = datetime.strptime(input, "%d/%m/%y") print d ~Sean -- http://mail.python.org/mailman/listinfo/python-list