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
   322   323   324   325   326   327   328   329   330   331   332