Graps Graps wrote:

aDict is a dictionary, containing

{0: 'str1\n', 1: 'str22\n', 2: 'str3\n', 3: 'str4\n', 4: 'str5\n', ..........., , 1308: 'str1309\n'}.

Are you saying that string is exactly what is in the file "aDict.py"? In that case, you can't import it. The expression will be evaluated, and then discarded. You would have to read it as a string and use "eval":
   aDict = eval( open( 'aDict.py', 'r' ).read() )

However, because that's dangerous, I strongly recommend that you change aDict.py so that it reads:
   aDict = {0: 'str1\n', 1: 'str2\n', ... }

That way, you COULD use
  from aDict import aDict


I used:

keys = m
values = noDupes
aDict = dict(zip(keys,values))

to get aDict, where m=range(1309) and noDupes was a list read from a text file.

OK, then why use a dictionary at all? If the indices are just sequential numbers, why not just make it a list:
   aList = [ 'str1\n', 'str2\n', 'str3\n', 'str4\n' ... ]

You would use it exactly the same way:
   from aDict import aList
   ...
   newValue = aList[ i ]

--
Tim Roberts, [EMAIL PROTECTED]
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to