Skip to content

Commit 0f4fbbc

Browse files
committed
improve docstring
1 parent dc9b1c2 commit 0f4fbbc

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

unpythonic/misc.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,17 +144,25 @@ def pack(*args):
144144
145145
We provide this because the default constructor `tuple(...)` requires an
146146
iterable, and there are use cases (especially in Python 3.4, before PEP 448)
147-
where being able to say "pack your args" is useful.
147+
where it is useful to be able to say *pack these args into a tuple*.
148148
149149
See:
150150
https://www.python.org/dev/peps/pep-0448/
151151
152-
Example::
152+
Examples. If args naturally come in separately::
153153
154154
myzip = lambda lol: map(pack, *lol)
155155
lol = ((1, 2), (3, 4), (5, 6))
156156
for z in myzip(lol):
157157
print(z)
158+
159+
Eliminate an ugly trailing comma::
160+
161+
@looped_over(zip((1, 2, 3), ('a', 'b', 'c')), acc=())
162+
def p(loop, item, acc):
163+
numb, lett = item
164+
return loop(acc + pack("{:d}{:s}".format(numb, lett)))
165+
assert p == ('1a', '2b', '3c')
158166
"""
159167
return args
160168

0 commit comments

Comments
 (0)