Gems in the python standard library
-
Upload
jasonscheirer -
Category
Technology
-
view
525 -
download
0
Transcript of Gems in the python standard library
![Page 1: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/1.jpg)
Gems in the Python Standard Library
Jason Scheirer
![Page 2: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/2.jpg)
Cool stuff!
• File formats
• Compression
• Algorithms and data structures
• Networking
• Package distribution
• All built in!
![Page 3: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/3.jpg)
File formats
![Page 4: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/4.jpg)
CSV
![Page 5: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/5.jpg)
JSON
• Simple python data structures to/from JSON strings
• Use in conjunction with urllib2 for great success!
![Page 6: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/6.jpg)
XML
• Three options:
- DOM (familiar to Javascript developers)
- SAX (event driven, big data)
- ElementTree (feels like Python)
![Page 7: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/7.jpg)
XML
![Page 8: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/8.jpg)
XML
![Page 9: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/9.jpg)
XML
![Page 10: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/10.jpg)
XML
![Page 11: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/11.jpg)
XML
![Page 12: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/12.jpg)
Compression
• GZip compression
-
• ZipFile
- Access zip file’s contents
- Put data in:
- Get data out:
![Page 13: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/13.jpg)
Algorithms and data structures
![Page 14: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/14.jpg)
Algorithms and data structures
• : Functional programming
• and : A great combination
![Page 15: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/15.jpg)
Algorithms and data structures
![Page 16: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/16.jpg)
Algorithms and data structures
• : Useful data structures
•
• (you probably want this a LOT)
![Page 17: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/17.jpg)
Algorithms and data structures
• : C-style data structures
• Equivalent to:
![Page 18: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/18.jpg)
Algorithms and data structures
• : Memory-efficient homogenous arrays
• You probably want , but this is nice too
![Page 19: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/19.jpg)
Networking
• module for low-level TCP programming
• Probably care more about HTTP though
![Page 20: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/20.jpg)
Networking (HTTP)
• Kind of messy organization in Python 2.X
• Fetching:
• Parsing:
![Page 21: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/21.jpg)
Package distribution
• Distutils
• You can provide Windows installers (.exe or .msi) for
your code libraries
• Semi-automatic compilation of C/C++ libraries
![Page 22: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/22.jpg)
Package distribution
• Layout:
•
• Setup.py:
![Page 23: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/23.jpg)
Package distribution
•
• Setup.py:
![Page 24: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/24.jpg)
Package distribution
![Page 25: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/25.jpg)
Package distribution
•
![Page 26: Gems in the python standard library](https://reader033.fdocuments.us/reader033/viewer/2022042518/55a9f04e1a28ab9e418b472d/html5/thumbnails/26.jpg)
QUESTIONS