Re: [Tutor] Change a text string from a list and change it into an integer number.(WinXP/py2.6.2/Beginner)

2009-11-06 Thread Alan Gauld
"Katt" wrote date = "cyear_11_05" date2 = date.split("_") check_year = date2[0] if check_year == "cyear": year = localtime().tm_year else: year = int(date2[0]) print year Did I do the slice incorrectly? I thought that when you take the first location (0) of a list then it would take t

Re: [Tutor] Retrieving information from a plain text file(WinXP/py2.6.2/Beginner)

2009-11-06 Thread Alan Gauld
"Katt" wrote (Looks like maybe you hijacked another thread, instead of just creating a new message, with new topic, for the list) Sorry, about that. I got lazy and just replied to a tutor message I had in my inbox. Will make sure not to let that happen again. Looks like it happened agai

Re: [Tutor] Evaluating a string expression

2009-11-06 Thread Alan Gauld
"Modulok" wrote I would like to know how would I evaluate a string expression in python. For example, if i say: a = "3*2" I want to do something to evaluate the variable 'a' to give me 6. How can I do this? [/snip] The eval() function can do this: eval("3*2") WARNING: Long winded securi