You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by sr...@apache.org on 2016/01/23 12:36:37 UTC

spark git commit: [SPARK-12760][DOCS] invalid lambda expression in python example for …

Repository: spark
Updated Branches:
  refs/heads/master 358a33bbf -> 56f57f894


[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 <mo...@gmail.com>

Closes #10867 from mortada/doc_python_fix.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/56f57f89
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/56f57f89
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/56f57f89

Branch: refs/heads/master
Commit: 56f57f894eafeda48ce118eec16ecb88dbd1b9dc
Parents: 358a33b
Author: Mortada Mehyar <mo...@gmail.com>
Authored: Sat Jan 23 11:36:33 2016 +0000
Committer: Sean Owen <so...@cloudera.com>
Committed: Sat Jan 23 11:36:33 2016 +0000

----------------------------------------------------------------------
 docs/programming-guide.md | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/56f57f89/docs/programming-guide.md
----------------------------------------------------------------------
diff --git a/docs/programming-guide.md b/docs/programming-guide.md
index bad25e6..4d21d43 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>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org