GET /api/v2/video/395
HTTP 200 OK Vary: Accept Content-Type: text/html; charset=utf-8 Allow: GET, PUT, PATCH, HEAD, OPTIONS
{ "category": "PyCon US 2011", "language": "English", "slug": "pycon-2011--useful-namespaces--context-managers-a", "speakers": [ "Jack Diederich" ], "tags": [ "contextmanagers", "decorators", "namespaces", "pycon", "pycon2011" ], "id": 395, "state": 1, "title": "Useful Namespaces: Context Managers and Decorators", "summary": "", "description": "Useful Namespaces: Context Managers and Decorators\n\nPresented by Jack Diederich\n\nPython has two useful conventions for \"I mean it, but only here\" and you can\nsay it with Context Managers and Decorators. Both give you the power to define\na push/pop of a resource for a set period inside a namespace, be it a function\nor a level of indentation. This talk is a list of patterns that are\nimplemented by one or the other (including some clever functions that are\nboth).\n\nAbstract\n\n * Decorators, formal definition. \n * Context Managers, formal definition. \n * Informal definition: both have the opportunity to do and then undo. - very similar to C++ RIIA \"Resource Acquisition Is Initialization.\" - Context Managers were designed to do that but decorators are frequently just as good. \n * Which one to use use when is all about namespaces. - Context Managers manipulate at the block level. - Function Decorators manipulate the function level. - Class Decorators manipulate at the class level. \n * Recipes on writing decorators and context managers - Familiar examples from Django and Mock. \n\n", "quality_notes": "", "copyright_text": "Creative Commons Attribution-NonCommercial-ShareAlike 3.0", "embed": "", "thumbnail_url": "", "duration": null, "video_ogv_length": 127109542, "video_ogv_url": null, "video_ogv_download_only": false, "video_mp4_length": null, "video_mp4_url": "", "video_mp4_download_only": false, "video_webm_length": null, "video_webm_url": null, "video_webm_download_only": false, "video_flv_length": null, "video_flv_url": null, "video_flv_download_only": false, "source_url": "", "whiteboard": "", "recorded": "2011-03-11", "added": "2012-02-23T04:20:00", "updated": "2014-04-08T20:28:28.056" }