471,310 Members | 1,031 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Dreams-program giving me trouble

Hi guys, it's me! Your least favourite tard has returned with noob-questions needing answers. I am working on making a program that will not only record my dreams in a file, but also store them by date, topic, keywords, and level of lucidness.

This is what I have so far:

Expand|Select|Wrap|Line Numbers
  1. ListOfKeywords=[]
  2. ListOfDates=[]
  3. ListOfTopics=[]
  4. LevelOfLucidness=[]
  5.  
  6.  
  7. temporarykeywords=[]
  8.  
  9. for n in [10]:
  10.     InputKeywords=raw_input("Give a keyword for finding this dream again. ")
  11.     temporarykeywords.append(InputKeywords)
  12.     needmore=raw_input("Are there more keywords? ")
  13.     if needmore.lower()=="no":
  14.         break
  15.  
  16.  
  17. for item in temporarykeywords:
  18.     ListOfKeywords.append(item)
  19.  
  20. DateOfDream=raw_input("What date did you have the dream on? ")
  21. if DateOfDream in ListOfDates:
  22.     print
  23. else:
  24.     ListOfDates.append(DateOfDream)
  25.  
  26.  
  27.  
  28. TheTopicIs=raw_input("What topic was the dream on? ")
  29. if TheTopicIs in ListOfTopics:
  30.     print
  31. else:
  32.     ListOfTopics.append(TheTopicIs)
  33.  
  34.  
  35.  
  36. HowLucid=raw_input("How lucid was the dream? ")
  37. if HowLucid in LevelOfLucidness:
  38.     print
  39. else:
  40.     LevelOfLucidness.append(HowLucid)
  41.  
  42.  
  43.  
  44. Recountation=raw_input("Now explain the dream. ")
  45.  
  46. DreamInfo=[temporarykeywords,DateOfDream,TheTopicIs,HowLucid]
  47.  
The problem I've encountered is: I need to make it append the stuff that gets added to the lists on the top to similar lists in another .py file. It also needs to be able to read those lists when I start the program, add all the items in them to the lists in this program, so that no word will ever be repeated in any list in the two files.

That's all for now, but if I get an answer to this, and try to continue, there WILL be more questions, brace yourselves.
Oct 20 '07 #1
2 1056
You should search Python doc files about: pickle
Oct 20 '07 #2
bartonc
6,596 Expert 4TB
Like this:
Expand|Select|Wrap|Line Numbers
  1. import cPickle as db  # an easy database
  2.  
  3. myDatabase = open('dreams.pdb', 'w') # create a file
  4.  
  5. myList = ['hello world']
  6. db.dump(myList, myDatabase) # pickle database
  7. myDatabase.close()
  8. del myList  # you progams quits (simulated)
  9.  
  10.  
  11. # then later
  12.  
  13. myDatabase = open('dreams.pdb') # open the previously created a file
  14. myList = db.load(myDatabase)
  15. myDatabase.close()
  16. print myList
Really, BurnTard; please feel free to ask all the questions that you need to.
Remember: There are no stupid questions; only stupid answers.
Oct 20 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Red | last post: by
1 post views Thread by Rich | last post: by
12 posts views Thread by user | last post: by
11 posts views Thread by yoda | last post: by
33 posts views Thread by amerar | last post: by
reply views Thread by manu | last post: by
reply views Thread by U S Contractors Offering Service A Non-profit | last post: by
reply views Thread by hux19383 | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.