Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How use python on ipad?

Tags:

python

ipad

Recently, I've found that the ipad can run python with a special python interpret. But editing the code on ipad is a terrible nightmare. So how can I push the python code which has been edited completely on PC into the ipad and run it?

like image 286
Peter Avatar asked Aug 17 '12 08:08

Peter


5 Answers

you may be interesting in https://www.pythonanywhere.com project.

I am using it on ipad too.

like image 133
Dmitry Zagorulkin Avatar answered Oct 04 '22 08:10

Dmitry Zagorulkin


If you are using Python for IOS, the following should work, although I haven't yet tried it myself.

Email the program to your own e-mail account as text. Then read the e-mail message on your iPad in any one of several e-mail applications. Cut and paste the text from the e-mail message into the python editor.

Don't cut and paste the code into the interpreter. Then you can't save it, at least not in the current version of Python for IOS. Instead, click on the second icon on the bottom (I think that's the icon, my iPad is at home and I'm not home now), to open the editor. You can save files from the editor using the menu button on the upper right; there's a "save" menu item that allows saving the code to a file on the iPad.

I'll be trying this tonight. Sorry for posting this before trying it, but I'm not sure I'll return to this question later. It 'should' work. (Famous last words!)

like image 43
Bill H Avatar answered Oct 01 '22 08:10

Bill H


If you're just running command-line Python, then you can edit it and/or upload it to a server and then run it from an iPad ssh terminal client. I know that's not the same as pushing it onto the iPad, and it requires a server and an internet connection, but it's the easiest way.

Otherwise, include a Python interpreter in your app and a UITextView that prints its outputs. Edit the code on your PC (or Mac, I guess), as a file in your Xcode project, and have the interpreter run that code and show the output in the UITextView.

like image 39
Yusuf X Avatar answered Oct 02 '22 08:10

Yusuf X


Pythonista for Ipad: save a script from the web in the Ipad

Pythonista is a great app for python on the ipad. If you use a bluetooth keyboard it can be also easier to digit (I use the logitech keyboard and it's great). Save it to your github repository (or any other site). Go into pythonista and run this script (python 3):

from urllib.request import urlopen
import os

file = "test_es1.py"
url = urlopen("https://formazione.github.io/" + file)
content = url.read()
p = ""
with open(file, "w") as new_file:
    content = content.decode("utf-8")
    print(content)
    new_file.write(content)
os.startfile(file)

Now, you have saved the file from you site to pythonista, you can open it from the app and run it.

like image 36
PythonProgrammi Avatar answered Sep 30 '22 08:09

PythonProgrammi


I use Python 2.7 for IOS and download source python files through iFunBox into /var/mobile/Applications/Python 2.7 for IOS/Documents/User Scripts. Nevertheless I can't recommend this application as it's quite buggy and very slow when editing code.

like image 36
Yury Kashnitskiy Avatar answered Sep 30 '22 08:09

Yury Kashnitskiy