Help with creating Python Session Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chintan85
    New Member
    • Jun 2010
    • 33

    Help with creating Python Session Files

    Hi,

    I want to create session files for my output.
    And this data file will be stored in the server.

    Thanks in Advance

    So its like this

    Code:
    ....
    
    session_file= open(path/../cy2.sif)
    ....
    ....
    
    print >>session_files, %s %s % (v[0] v[1])
    
    v[0] and v[1] are some array consisting info to be written in cy2.sif file.
    Can you please help me how can I create session for the file cy2.sif
  • bvdet
    Recognized Expert Specialist
    • Oct 2006
    • 2851

    #2
    You cannot write to a file opened for reading. Open the file in "w" or "a" mode.
    Code:
    >>> f = open("foo.txt", 'w')
    >>> v = ((1,2),(10,20),(100,200))
    >>> for item in v:
    ... 	print >> f, "%s %s" % item
    ... 	
    >>> f.close()
    >>>
    In your code, the tuple that accompanies the format string is missing a comma.
    Last edited by bvdet; Aug 27 '10, 12:51 AM.

    Comment

    • chintan85
      New Member
      • Jun 2010
      • 33

      #3
      thanks so much..

      But how to make this files as session files

      Comment

      • bvdet
        Recognized Expert Specialist
        • Oct 2006
        • 2851

        #4
        I don't know what a session file is. Can you provide more information or a detailed example?

        Comment

        Working...