Skip to content

Commit

Permalink
Adding Python doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
kanzhang committed May 8, 2014
1 parent 473ec4b commit c62ad33
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions python/pyspark/rdd.py
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,14 @@ def saveAsTextFile(self, path):
>>> from glob import glob
>>> ''.join(sorted(input(glob(tempFile.name + "/part-0000*"))))
'0\\n1\\n2\\n3\\n4\\n5\\n6\\n7\\n8\\n9\\n'
Empty lines are tolerated when saving to text files.
>>> tempFile2 = NamedTemporaryFile(delete=True)
>>> tempFile2.close()
>>> sc.parallelize(['', 'foo', '', 'bar', '']).saveAsTextFile(tempFile2.name)
>>> ''.join(sorted(input(glob(tempFile2.name + "/part-0000*"))))
'\\n\\n\\nbar\\nfoo\\n'
"""
def func(split, iterator):
for x in iterator:
Expand Down

0 comments on commit c62ad33

Please sign in to comment.