Last active
December 20, 2015 13:19
-
-
Save anandology/6137954 to your computer and use it in GitHub Desktop.
Advanced Python Workshop
August 2-4, 2013
http://advancedpython.hasgeek.com/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"metadata": { | |
"name": "Advanced Python Workshop - Practice Problems" | |
}, | |
"nbformat": 3, | |
"nbformat_minor": 0, | |
"worksheets": [ | |
{ | |
"cells": [ | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"# Advanced Python Workshop - Practice Problems\n", | |
"[[Day 1]](http://nbviewer.ipython.org/6137954/Advanced%20Python%20Workshop%20-%20Day%201.ipynb) - \n", | |
"[[Day 2]](http://nbviewer.ipython.org/6137954/Advanced%20Python%20Workshop%20-%20Day%202.ipynb) - \n", | |
"[[Day 3]](http://nbviewer.ipython.org/6137954/Advanced%20Python%20Workshop%20-%20Day%203.ipynb) -\n", | |
"[[Practice Problems]](http://nbviewer.ipython.org/6137954/Advanced%20Python%20Workshop%20-%20Practice%20Problems.ipynb)\n", | |
"\n", | |
"August 2-4, 2013 <br/>\n", | |
"by [Anand Chitipothu](http://anandology.com/) <br/>\n", | |
"<http://advancedpython.hasgeek.com/>" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Slides Used in the workshop\n", | |
"\n", | |
"* [Python Warmup](http://anandology.com/apy/slides/python-warmup.html)\n", | |
"* [Classes](http://anandology.com/apy/slides/classes.html)" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"## Practice Problems" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"**Higher-Order Functions and Decorators**" | |
] | |
}, | |
{ | |
"cell_type": "markdown", | |
"metadata": {}, | |
"source": [ | |
"**Problem:** Write a decorator function `with_retries` to allowing calling a function again after sometime if it fails with an exception.\n", | |
"\n", | |
" @with_retries(retries=10, wait_time=5)\n", | |
" def wget(url):\n", | |
" return urllib.urlopen(url).read()\n", | |
"\n", | |
"The `with_reties` function takes two optional arguments `retries` and `wait_time`. The `retries` specifies how many times the function should keep trying in case of failures and `wait_time` specified the time to wait between retries in seconds." | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"collapsed": false, | |
"input": [], | |
"language": "python", | |
"metadata": {}, | |
"outputs": [] | |
} | |
], | |
"metadata": {} | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment