Page 327 -
P. 327
mobile app development
Your Python Toolbox
You’ve got Chapter 8 under your
belt and you’ve added some key
Python techiques to your toolbox. CHAPTER 8
Python Lingo The json library module lets you
• “Python 2” - the previous release convert Python’s built-in types to the text-
of Python, which has compatibility
based JSON data interchange format.
“issues” with Python 3 (and are not Use json.dumps() to create a
worth getting worked up over).
stringed version of a Python type.
Use json.loads() to create a
Python type from a JSON string.
Data sent using JSON needs to
have its Content-Type: set to
Android Lingo application/json.
The urllib and urllib2 library
• “SL4A” - the Scripting Layer modules (both available in Python 2)
for Android lets you run Python on can be used to send encoded data from
your Android device. a program to a web server (using the
urlencode() and urlopen()
• “AVD” - an Android Virtual functions).
Device which lets you emulate your
The sys module provides the sys.
Android device on your computer.
stdin, sys.stdout and sys.
stderr input streams.
you are here 4 291