×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Oct 2009
    Posts
    26

    Python doesn't write text file on phone

    Hi all,

    I made a simple script that works on my PC, but doesn't on my phone. It's just this:

    Code:
    filename = "test83.txt"
    
    x = 'hello world'
    
    FILE = open(filename,"w")
    FILE.writelines(x)
    FILE.close()
    So on my PC it creates a textfile with 'hello world' in the same directory as the .py script. But on my phone nothing happens - no file is created. Might there be some sort of restriction that my script is not allowed to write files?
    I'm using a nokia 5800 (fw 21.0.025), with Python 1.9.4 runtime and 1.9.4 script shell. I am running the script from script shell.

  2. #2
    Regular Contributor
    Join Date
    Nov 2007
    Posts
    147

    Re: Python doesn't write text file on phone

    It does create just not in the directory that you are expecting. The above example created the file in the PRIVATE directory of scriptshell that you can't access.

    Your best option is to provide a full path. If you want to create it in the directory where the script is located I think
    Code:
    os.getcwd()
    will give that to you.

    raf
    http://www.bdcsoftware.com/development-blog

  3. #3
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Python doesn't write text file on phone

    I would recommend using c:\data or e:\data directory, can be accessed freely by anyone.

    Cheers,

    --jouni

  4. #4
    Registered User
    Join Date
    Mar 2009
    Posts
    1

    Re: Python doesn't write text file on phone

    filename = u"E:\system\Apps\Python\test83.txt"

    x = 'hello world'

    FILE = open(filename,"w")
    FILE.writelines(x)
    FILE.close()



    #complete pathname is required
    # u signifies unicode file
    #E drive is MemCard
    #C drive is phone memory, D is RAM, Z is ROM

Similar Threads

  1. Replies: 24
    Last Post: 2010-10-11, 15:29
  2. Not able to write the file on the Cell phone
    By sumeet_netsmartz in forum Mobile Java General
    Replies: 8
    Last Post: 2009-08-21, 13:17
  3. [announce] PyUIQ. Python for UIQ 2.1 and 3.x
    By OscarBernabeu in forum Symbian
    Replies: 35
    Last Post: 2008-01-17, 09:12
  4. Replies: 1
    Last Post: 2007-12-18, 07:58
  5. nokia 7210 modem via IR doesn't work !
    By oussamaaiadi in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-03-06, 10:46

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×