aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorMortada Mehyar <mortada.mehyar@gmail.com>2016-01-23 11:36:33 +0000
committerSean Owen <sowen@cloudera.com>2016-01-23 11:36:33 +0000
commit56f57f894eafeda48ce118eec16ecb88dbd1b9dc (patch)
tree43b0b37647f99eb7a9437a65e78c298c1a65bfce /docs
parent358a33bbff549826b2336c317afc7274bdd30fdb (diff)
downloadspark-56f57f894eafeda48ce118eec16ecb88dbd1b9dc.tar.gz
spark-56f57f894eafeda48ce118eec16ecb88dbd1b9dc.tar.bz2
spark-56f57f894eafeda48ce118eec16ecb88dbd1b9dc.zip
[SPARK-12760][DOCS] invalid lambda expression in python example for …
…local vs cluster srowen thanks for the PR at https://github.com/apache/spark/pull/10866! sorry it took me a while. This is related to https://github.com/apache/spark/pull/10866, basically the assignment in the lambda expression in the python example is actually invalid ``` In [1]: data = [1, 2, 3, 4, 5] In [2]: counter = 0 In [3]: rdd = sc.parallelize(data) In [4]: rdd.foreach(lambda x: counter += x) File "<ipython-input-4-fcb86c182bad>", line 1 rdd.foreach(lambda x: counter += x) ^ SyntaxError: invalid syntax ``` Author: Mortada Mehyar <mortada.mehyar@gmail.com> Closes #10867 from mortada/doc_python_fix.
Diffstat (limited to 'docs')
-rw-r--r--docs/programming-guide.md7
1 files changed, 5 insertions, 2 deletions
diff --git a/docs/programming-guide.md b/docs/programming-guide.md
index bad25e63e8..4d21d4320c 100644
--- a/docs/programming-guide.md
+++ b/docs/programming-guide.md
@@ -789,9 +789,12 @@ counter = 0
rdd = sc.parallelize(data)
# Wrong: Don't do this!!
-rdd.foreach(lambda x: counter += x)
+def increment_counter(x):
+ global counter
+ counter += x
+rdd.foreach(increment_counter)
-print("Counter value: " + counter)
+print("Counter value: ", counter)
{% endhighlight %}
</div>