• dgelessus

    Pythonista 3 supports both Python 2 and 3, and as far as I know no functionality was "lost" from Pythonista 2 to 3. The only difference is that Pythonista 3's Python 2 is perhaps a few minor versions newer (i. e. still backwards compatible) and that some libraries might be updated.

    If you still have files in Pythonista 2, you can move them over to Pythonista 3 by enabling "Pythonista 2 Files" in the Pythonista 3 settings. That will show a special folder in Pythonista 3 with your Pythonista 2 files in it. You can then move them over and run them with Pythonista 3's Python 2. Once you've checked that they still work, it should be safe to delete Pythonista 2. In the worst case, you can still redownload Pythonista 2 from your purchases.

    posted in General Discussion read more
  • dgelessus

    Does Dottable provide any export options other than the iOS photo library? If it has a way to export the image with the standard iOS share sheet, you can use Pythonista's share extension to import the file.

    The share extension might not be enabled by default, in that case you have to open a share sheet, scroll to the far right of the bottom row, tap on "More", then enable Pythonista in the list. Once that's done, you can share the file into Pythonista's share extension, and there you'll get an "Import File" option.

    posted in Editorial read more
  • dgelessus

    Are you using Python 2 or 3? There are some known problems in the current Pythonista version, where using matplotlib in Python 2 crashes the app. Unfortunately this has not been fixed yet, so for now if you want to use matplotlib, you need to use Python 3. (The default Python version can be changed under "Default Interpreter" in the Pythonista settings.)

    posted in Pythonista read more
  • dgelessus

    It should be enough to put your entire main code into a while True loop. That way it will repeat forever (until you press the stop button - that raises an exception, which stops the loop).

    posted in Pythonista read more
  • dgelessus

    I think the Python console uses the globals of the __main__ module, which corresponds to the script that was last run. I'm not sure how exactly the globals from pythonista_startup are initially copied into the console globals, it seems that is done in C rather than in pykit_startup. In any case, I'm guessing this copying only happens once, so if you add globals to pythonista_startup afterwards, they won't appear in the console. However when Pythonista clears the console globals (using pykit_preflight) when running a new script, it does look at pythonista_startup's globals to determine what to keep.

    So I think (I haven't tested this) to add console globals after pythonista_startup has finished running, you need to add the global to both the __main__ and pythonista_startup modules. If you're doing this in a function in pythonista_startup, that means you need to declare the variable as global, set it, and also set an attribute on __main__ with the same name.

    posted in Pythonista read more
  • dgelessus

    (why twice?)

    Because the pythonista_startup module is imported by both the Python 2 and 3 interpreters. (Both are started at the same time, even if you only use one.) If you change the code to print x, it will run in Python 2 but cause an exception in Python 3 (and all exceptions from pythonista_startup are silently ignored).

    posted in Pythonista read more
  • dgelessus

    Does it have something to do with which apps the files are stored in? On my device (iPhone SE, iOS 10.3.3) dialogs.pick_document() lets me pick any file from most apps (including files in the "main" iCloud Drive part that is not in any app folder), but in some apps (for example Pages) no files can be selected at all.

    posted in Pythonista read more
  • dgelessus

    Is the file with your code called discord.py perhaps? If so, you need to rename it - otherwise when you say import discord, it will import your own script instead of the discord module.

    Also just FYI, it's not possible to have a Python script run while Pythonista is in the background - iOS does not allow apps to run in the background for a long time. I don't know anything about writing Discord bots, but I assume that you have to keep your script running in order for the bot to work. So if you want your bot to always run, without having to start it manually first, you're probably better off running it on a regular computer instead of a mobile device.

    posted in Pythonista read more
  • dgelessus

    This comes from a new feature in iOS 11, called "smart punctuation". It changes some punctuation into nicer/more "correct" characters, for example it replaces "--" (two minuses) with "–" (an "em dash"), as you discovered. This is nice when writing normal text, but causes problems when writing code. You can turn this feature off in the iOS Settings app, under General > Keyboard. (If you have a hardware keyboard, you may also have to turn it off again under the "Hardware Keyboard" section.)

    If this doesn't work, you can probably copy and paste the text from the instructions that you're following. The pasted text shouldn't be changed by any of the iOS text replacement features.

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!