• tbrown313

    @ccc: Thanks for the comment. FYI, the identation in the first code block is only in this post and resulted from a copy and paste error.

    Thanks for the detail on

    with open() as

    I'm an old hardware designer who wrote a lot of internal diagnostics code that was never for production and the depth of my knowledge of such details is scant. This helps me.


    Unfortunately, I think you are correct about iCloud, and it is very disappointing. It is interesting that I have had good luck with some apps that use iCloud--like Drafts, for example--that seem much more reliable than Apple's efforts--like Notes, for example. I am going to play with storing my data in Drafts to see it that works more reliably.

    Also, as a workaround when I notice a missed update failure, I found this on the forum:


    The last comment suggests a technique to force an iCloud update in Pythonista and I have had a bit of luck with that.

    Maybe this is a question for a separate thread, but what is the effect of running a gui pythonista app multiple times from a shortcut without closing the Pythonista gui app? If I do this (my gui is less that full screen size), then the Pythonista gui app windows just stack up. Doesn't seem like a good thing, but if I handle the opening/closing of files properly, is this a problem? Of course, I wouldn't want a few hundred of them stacked up--but I would notice eventually and close them :).

    posted in Pythonista read more
  • tbrown313

    I have written a Pythonista script using the ui to create and update multiple files that are stored in the Pythonista directory of iCloud. I run the script using a shortcut and I run it from both my iPhone and my iPad.

    The problem is that when going back and forth between the iPhone and iPad accessing and modifying the same files, sometimes the files are not synchronized.

    In the Pythonista file browser, the files, and the script are in iCloud/Pythonista3/Books directory.

    For one file where I get this type of error, I open the file every time the program is run using:

    myfile = open ('CurrentBooks.txt').read()
        cBooks = json.loads(myfile)

    The file is not explicitly closed when it is only read.

    When I change the file, then I do the following:

    with open('CurrentBooks.txt', 'w') as outfile:
            json.dump(mydict, outfile)

    But I have found that, sometimes, when I add an entry to this file using the iPad, when I access the file on the iPhone, the changes are not there.

    What is going on? Is this an iCloud problem? Or am I doing something wrong in the code?

    Also, I wonder if this type of operation can get confused if the gui portion of the app is open at the same time on both devices. Since there appears to be no way to close the gui app from Pythonista, I have to remember to touch the 'X' to close the app each time I run it. I am sure that at times I have not done this.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!