Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Type Python, Press Enter, What Happens? - PyDX ...

Type Python, Press Enter, What Happens? - PyDX 2015

The slides from my talk at PyDX

Philip James

October 11, 2015
Tweet

More Decks by Philip James

Other Decks in Technology

Transcript

  1. paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)

    [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython
  2. paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)

    [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2
  3. paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)

    [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2 4 >>>
  4. paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)

    [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2 4 >>> KeyboardInterrupt >>>
  5. paulproteus@vellum:~ $ python Python 2.7.6 (default, Apr 11 2014, 22:59:56)

    [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython 2+2 4 >>> KeyboardInterrupt >>> paulproteus@vellum:~ $
  6. paulproteus@vellum:~ $ hexdump -C /usr/bin/python 00000000 7f 45 4c 46

    02 01 01 00 00 00 00 00 00 00 00 00 |.ELF............| 00000010 02 00 3e 00 01 00 00 00 55 49 57 00 00 00 00 00 |..>.....UIW.....| 00000020 40 00 00 00 00 00 00 00 08 15 33 00 00 00 00 00 |@.........3.....| 00000030 00 00 00 00 40 00 38 00 09 00 40 00 1c 00 1b 00 |[email protected]...@.....| 00000040 06 00 00 00 05 00 00 00 40 00 00 00 00 00 00 00 |........@.......| 00000050 40 00 40 00 00 00 00 00 40 00 40 00 00 00 00 00 |@.@.....@.@.....| 00000060 f8 01 00 00 00 00 00 00 f8 01 00 00 00 00 00 00 |................| 00000070 08 00 00 00 00 00 00 00 03 00 00 00 04 00 00 00 |................| 00000080 38 02 00 00 00 00 00 00 38 02 40 00 00 00 00 00 |8.......8.@.....| 00000090 38 02 40 00 00 00 00 00 1c 00 00 00 00 00 00 00 |8.@.............| @phildini #typepython
  7. for dir in os.getenv( 'PATH').split(':'): try: os.stat(dir + '/python') return

    dir except: pass raise CommandNotFound() @phildini #typepython
  8. # installing zipimport hook import zipimport # builtin # installed

    zipimport hook # /usr/lib/python2.7/site.pyc matches /usr/lib/python2.7/site.py import site # precompiled from /usr/ lib/python2.7/site.pyc # /usr/lib/python2.7/os.pyc matches /usr/lib/python2.7/os.py paulproteus@vellum:~ $ python -v @phildini #typepython
  9. bash pid: 1221 fork() python pid: 1222 argv = [‘python’,

    ‘-v’] exec( ‘/usr/bin/python’, [‘python’, ‘-v’] ) @phildini #typepython
  10. Python 2.7.6 (default, Apr 11 2014, 22:59:56) [GCC 4.8.2] on

    linux2 Type "help", "copyright", "credits" or "license" for more information. >>> @phildini #typepython
  11. paulproteus@vellum:~ $ strace python [...] read(0, “2”, 1) read(0, “+”,

    1) read(0, “2”, 1) read(0, “\n”, 1) 2 + 2 Enter @phildini #typepython
  12. while True: line = ‘’ chr = sys.stdin.read(1) line +=

    chr if chr == ‘\n’: print eval(line) @phildini #typepython
  13. while True: line = ‘’ chr = sys.stdin.read(1) line +=

    chr if chr == ‘\n’: print eval(line) @phildini #typepython
  14. bash pid: 1221 python pid: 1222 0: /dev/pts/3 1: /dev/pts/3

    2: /dev/pts/3 0: /dev/pts/3 1: /dev/pts/3 2: /dev/pts/3 @phildini #typepython
  15. bash pid: 1221 python pid: 1222 0: /dev/pts/3 1: /dev/pts/3

    2: /dev/pts/3 0: /dev/pts/3 1: /dev/pts/3 2: /dev/pts/3 foreground @phildini #typepython
  16. python pid: 1222 argv = [‘python’] 0: /dev/pts/3 1: /dev/pts/3

    2: /dev/pts/3 bash pid: 1221 @phildini #typepython
  17. python pid: 1222 argv = [‘python’] sigint sig pipe 0:

    /dev/pts/3 1: /dev/pts/3 2: /dev/pts/3 bash pid: 1221 @phildini #typepython