gems in the python standard library

26
Gems in the Python Standard Library Jason Scheirer

Upload: jasonscheirer

Post on 18-Jul-2015

537 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Gems in the python standard library

Gems in the Python Standard Library

Jason Scheirer

Page 2: Gems in the python standard library

Cool stuff!

• File formats

• Compression

• Algorithms and data structures

• Networking

• Package distribution

• All built in!

Page 3: Gems in the python standard library

File formats

Page 4: Gems in the python standard library

CSV

Page 5: Gems in the python standard library

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

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

XML

Page 8: Gems in the python standard library

XML

Page 9: Gems in the python standard library

XML

Page 10: Gems in the python standard library

XML

Page 11: Gems in the python standard library

XML

Page 12: Gems in the python standard library

Compression

• GZip compression

-

• ZipFile

- Access zip file’s contents

- Put data in:

- Get data out:

Page 13: Gems in the python standard library

Algorithms and data structures

Page 14: Gems in the python standard library

Algorithms and data structures

• : Functional programming

• and : A great combination

Page 15: Gems in the python standard library

Algorithms and data structures

Page 16: Gems in the python standard library

Algorithms and data structures

• : Useful data structures

• (you probably want this a LOT)

Page 17: Gems in the python standard library

Algorithms and data structures

• : C-style data structures

• Equivalent to:

Page 18: Gems in the python standard library

Algorithms and data structures

• : Memory-efficient homogenous arrays

• You probably want , but this is nice too

Page 19: Gems in the python standard library

Networking

• module for low-level TCP programming

• Probably care more about HTTP though

Page 20: Gems in the python standard library

Networking (HTTP)

• Kind of messy organization in Python 2.X

• Fetching:

• Parsing:

Page 21: Gems in the python standard library

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

Package distribution

• Layout:

• Setup.py:

Page 23: Gems in the python standard library

Package distribution

• Setup.py:

Page 24: Gems in the python standard library

Package distribution

Page 25: Gems in the python standard library

Package distribution

Page 26: Gems in the python standard library

QUESTIONS