Skip to content

Commit

Permalink
Small docstring additions
Browse files Browse the repository at this point in the history
  • Loading branch information
RobRuana committed Feb 19, 2015
1 parent 88c848a commit 8eab05a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pockets/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@ def is_listy(x):
True
>>> is_listy(set())
True
>>> is_listy(iter(["a", "b"]))
False
>>> is_listy({"a": "b"})
False
>>> is_listy("a regular string")
False
Note:
Iterables and generators fail the "listy" test because they
are not sized.
Args:
x (any value): The object to test.
Expand Down Expand Up @@ -59,6 +65,7 @@ def listify(x, minlen=0, default=None, cls=None):
Args:
x (any value): Value to listify.
minlen (int): Minimum length of the returned list. If the returned
list would be shorter than `minlen` it is padded with values from
`default`. Defaults to 0.
Expand Down Expand Up @@ -125,8 +132,10 @@ def mappify(x, default=True, cls=None):
Args:
x (str, map, or iterable): Value to mappify.
default (any value): Value used to fill out missing values of the
returned dict.
cls (class or callable): Instead of wrapping `x` in a dict, wrap it
in an instance of `cls`. `cls` should accept a map object as
its single parameter when called:
Expand Down
3 changes: 3 additions & 0 deletions pockets/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,19 @@ def splitcaps(s, pattern=None, maxsplit=None, flags=0):
Args:
s (str): The string to split.
pattern (str, optional): In addition to splitting on capital letters,
also split by the occurrences of `pattern`. If capturing
parentheses are used in `pattern`, then the text of all groups in
`pattern` are also returned as part of the resulting list.
Defaults to None.
maxsplit (int, optional): If maxsplit is not specified or -1, then
there is no limit on the number of splits (all possible splits are
made). If maxsplit is >= 0, at most maxsplit splits occur, and the
remainder of the string is returned as the final element of the
list.
flags (int, optional): Flags to pass to the regular expression created
using `pattern`. Ignored if `pattern` is not specified. Defaults
to (re.LOCALE | re.MULTILINE | re.UNICODE).
Expand Down

0 comments on commit 8eab05a

Please sign in to comment.