Dreams-program giving me trouble

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • BurnTard
    New Member
    • May 2007
    • 52

    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:

    [code=python]
    ListOfKeywords=[]
    ListOfDates=[]
    ListOfTopics=[]
    LevelOfLucidnes s=[]


    temporarykeywor ds=[]

    for n in [10]:
    InputKeywords=r aw_input("Give a keyword for finding this dream again. ")
    temporarykeywor ds.append(Input Keywords)
    needmore=raw_in put("Are there more keywords? ")
    if needmore.lower( )=="no":
    break


    for item in temporarykeywor ds:
    ListOfKeywords. append(item)

    DateOfDream=raw _input("What date did you have the dream on? ")
    if DateOfDream in ListOfDates:
    print
    else:
    ListOfDates.app end(DateOfDream )



    TheTopicIs=raw_ input("What topic was the dream on? ")
    if TheTopicIs in ListOfTopics:
    print
    else:
    ListOfTopics.ap pend(TheTopicIs )



    HowLucid=raw_in put("How lucid was the dream? ")
    if HowLucid in LevelOfLucidnes s:
    print
    else:
    LevelOfLucidnes s.append(HowLuc id)



    Recountation=ra w_input("Now explain the dream. ")

    DreamInfo=[temporarykeywor ds,DateOfDream, TheTopicIs,HowL ucid]
    [/code]

    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.
  • diegososa
    New Member
    • Oct 2007
    • 19

    #2
    You should search Python doc files about: pickle

    Comment

    • bartonc
      Recognized Expert Expert
      • Sep 2006
      • 6478

      #3
      Like this:[CODE=python]
      import cPickle as db # an easy database

      myDatabase = open('dreams.pd b', 'w') # create a file

      myList = ['hello world']
      db.dump(myList, myDatabase) # pickle database
      myDatabase.clos e()
      del myList # you progams quits (simulated)


      # then later

      myDatabase = open('dreams.pd b') # open the previously created a file
      myList = db.load(myDatab ase)
      myDatabase.clos e()
      print myList[/CODE]

      Really, BurnTard; please feel free to ask all the questions that you need to.
      Remember: There are no stupid questions; only stupid answers.
      Last edited by bartonc; Oct 20 '07, 07:48 PM.

      Comment

      Working...