Converting a string to a tuple

Bruce Huzyk bhuzyk at kodak.com
Wed Apr 14 09:45:34 EDT 1999


First let me thank everyone for their help.

Let me take a step back and try to describe my problem with a little more 
detail with the disclaimer that I am a little new to Python (but not 
programming, BTW I couldn't find the PEWBIE module) and that I am 
more of a newsgroup reader then writer so please excuse the fact that this 
is my third post.


I will list my solution and ask the question: Is this the way that you
would 
implement this?
Any side effects?


E:\PYTHON>type c:\batch\script1.py
import string

fp = open("c:\\test.txt", "r")
s = fp.readline()
s = s[2:]
a = {}
a['1'] = eval(string.replace(s, '\\', '\\\\'))
print type (a['1'])
filename, offset = a['1']
print filename, offset
fp.close

E:\PYTHON>python c:\batch\script1.py
<type 'tuple'>
c:\a\test.txt 1932

E:\PYTHON>type c:\test.txt
:R("c:\a\test.txt",1932)

E:\PYTHON>










More information about the Python-list mailing list