473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Python on iPhone actually rather good

Mini install guide for python on the iPhone:

Cydia =Install SSH helps make initial configuration easier until you
get used to MobileTerminal
Cydia =Install MobileTerminal (closest to a bash shell you get on
your iPhone currently)
Cydia =Install Finder (graphical alternative to using
SSH/MobileTerminal for setting permissions, navigating file system,
moving/copying files, etc.)
Cydia =Install Python (currently installs CPython 2.5.1)
Cydia =Install PyObjC (this is your hook into iPhone API)
Cydia =Install Setuptools (currently install 0.6c7)
Cydia =Install iPhone/Python (examples, the hello world is a PyObjC
call into the iPhone API to load and scroll the contacts list in the
phone)

Not much left to have a fast running python implementation in your
pocket except IMHO ipython. Now that you have Setuptools installed,
you can run easy_install directly on your iPhone and download iPython
over the air.

The iPhone OS X architecture is of course a BSD Unix Userland
environment so you should feel right at home.

The two accounts, root and mobile both share the same default password
'alpine'. So once you setup your phone I recommend you change the
password for each account right away just to secure your phone a
little more. Root you won't need, Mobile is what the default account
is on the current iPhone OS implementation for the standard user
(you).

Easiest way to access your phone is SSH from your Mac, Linux, or
Windows box. (or just use MobileTerminal.app on the iphone directly
keeping in mind you will default to the mobile account in the shell)
Simply join your iPhone over wifi to your wireless access point or
ad-hoc-network, and display your iPhone's ip address. Now you are
ready to ssh into it.
$ssh root@<your iphones ip address>
password: alpine
$chpass
<change your password for root>
while you are here might as well install ipython
$easy_install ipython
$exit

now same for mobile
$ssh root@<your iphone ip address>
password: alpine
$chpass
<change your password for mobile>

$ipython
<test your ipython if it loads, yes? good. now just exit()>

$cd .ipython
$nano ipy_user_conf.py
<or vi or emac or whatever you like, its easier for beginners to try nano>

CTRL+W (find)
Where: #import ipy_editors
<Now for those who are following along using MobileTerminal.app here
is a quick guesture routine
Single Tap screen to bring up a quick tap box grid of common unix
commands that get pasted when selected into the shell
Double Tap screen to hide the onscreen keyboard and see the full screen.
Drag Top left downward diagonally to right for CTRL
Drag Top right downward diagonally to left for TAB -- good for tab
completion in the bash shell

<ok back to editing ipy_user_conf.py>
Delete the # comment character

Scroll down <MobileTerminal.app users just drag up, down, left, or
right quickly for cursor movement>

Add your new line below the text "# Or roll your own"
ipy_editors.install_editors("nano +$line $file")

CTRL+X (exit)
Y to save

Now test your ipython link to nano editor
$ipython
In [1]: edit test.py
<nano should now launch and you can edit your python script on your
iPhone directly, when you save it, iPython will execute the python
code>
In [2]: exit()
$cat test.py
<your code should display, good now we are done>
$rm test.py <remove our test file>

Its up to you where you want to save your python scripts. I would
suggest in Documents under your account (mobile).
<for example launch MobileTermina.app>
$cd ~
$cd D* <or just D and try the tab completion gesture Top right
drag diagonally down to left>
$mkdir python <or whatever you want to call your directory>
What is missing? Tkinter, iPhone uses its own API, Desktop Manager
(Springboard), etc.
What is different? PyObjC, this is where you get to use those iPhone
API calls from within your python script on the iPhone including GUI
API calls.

Now you have Python in your Pocket that you can take anywhere and whip
it out anytime the Python bug hits you and you want to work on some
code.

You can use SSH to move/copy/sync your files to your desktop.
Or other ways: AirSharing app over wifi, etc.

I'll be giving iPhone Python 2.5.1 a workout on on of Mark Lutz's
books and report any more gotchas that I come across.

Cheers,
PN
Nov 4 '08 #1
0 19277

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
25
by: abhinav | last post by:
Hello guys, I am a novice in python.I have to implement a full fledged mail server ..But i am not able to choose the language.Should i go for C(socket API) or python for this project? What are the...
206
by: WaterWalk | last post by:
I've just read an article "Building Robust System" by Gerald Jay Sussman. The article is here: http://swiss.csail.mit.edu/classes/symbolic/spring07/readings/robust-systems.pdf In it there is a...
270
by: Jordan | last post by:
Hi everyone, I'm a big Python fan who used to be involved semi regularly in comp.lang.python (lots of lurking, occasional posting) but kind of trailed off a bit. I just wrote a frustration...
1
by: skip | last post by:
Anybody tried this port of Python to the iPhone? http://www.modmyi.com/nativeapps/python-v251/ http://iphone.natetrue.com/ Hasn't been updated since July 2007. Maybe just a proof-of-concept? ...
0
by: Python Nutter | last post by:
Yes it does involve Jailbreaking. Python GCC Java and Ruby are all available to run on the iPhone after you Jailbreak it. Just run the Cydia appliacation (jailbreak's AppStore) to install
0
by: Joe Strout | last post by:
On Nov 4, 2008, at 10:33 AM, Michael Torrie wrote: I've found "Cocoa Programming for Mac OS X", in combination with the PyObjC tutorials on the web, to be a very accessible combination. I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.