Skip to content

Commit

Permalink
Fix docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
TaurusOlson committed Mar 4, 2016
1 parent eb93458 commit cc540c4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions fntools/fntools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ def use_with(data, fn, *attrs):
:param attrs: some attributes of the object
:returns: an object
# Let's create some data first
Let's create some data first:
>>> from collections import namedtuple
>>> Person = namedtuple('Person', ('name', 'age', 'gender'))
>>> alice = Person('Alice', 30, 'F')
# Usage
Usage:
>>> make_csv_row = lambda n, a, g: '%s,%d,%s' % (n, a, g)
>>> use_with(alice, make_csv_row, 'name', 'age', 'gender')
'Alice,30,F'
Expand Down Expand Up @@ -369,11 +369,11 @@ def shift(func, *args, **kwargs):
>>> def div(x, y): return float(x) / y
# This is equivalent to div(42, 2):
This is equivalent to div(42, 2):
>>> shift(div, 2)(42)
21.0
# which is different from div(2, 42):
which is different from div(2, 42):
>>> from functools import partial
>>> partial(div, 2)(42)
0.047619047619047616
Expand Down Expand Up @@ -464,7 +464,7 @@ def pluck(record, *keys, **kwargs):
>>> pluck(d, 'name', 'color')
{'color': 'blue', 'name': 'Lancelot'}
# the keyword 'default' allows to replace a None value
The keyword 'default' allows to replace a None value:
>>> d = {'year': 2014, 'movie': 'Bilbo'}
>>> pluck(d, 'year', 'movie', 'nb_aliens', default=0)
{'movie': 'Bilbo', 'nb_aliens': 0, 'year': 2014}
Expand Down Expand Up @@ -500,12 +500,12 @@ def use(data, attrs):
:param attrs: strings
:returns: a list
# With a dict
With a dict:
>>> band = {'name': 'Metallica', 'singer': 'James Hetfield', 'guitarist': 'Kirk Hammet'}
>>> use(band, ('name', 'date', 'singer'))
['Metallica', None, 'James Hetfield']
# With a non dict data structure
With a non dict data structure:
>>> from collections import namedtuple
>>> Person = namedtuple('Person', ('name', 'age', 'gender'))
>>> alice = Person('Alice', 30, 'F')
Expand Down

0 comments on commit cc540c4

Please sign in to comment.