<div dir="ltr">Just write all your transformations at the top of the file and then write the mapreduce chain at the end. If you need to use closures that depend on each other then it may be a bit more ugly but still feasible to implement.<div><br><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div style="margin:0px 0px 8px"><p style="margin:0px"><font size="2"><span style="font-family:arial,helvetica,sans-serif">- Ron</span><br></font></p><p style="font-size:13.3px;font-family:Verdana,Arial,Helvetica,sans-serif;margin:0px"><br></p><p style="font-size:13.3px;font-family:Verdana,Arial,Helvetica,sans-serif;margin:0px"><a href="http://www.facebook.com/ron.reiter" style="font-size:13.3px" target="_blank"><img width="16" height="16" alt="Facebook" style="padding:0px 0px 5px 0px;vertical-align:middle" border="0" src="http://images.wisestamp.com/facebook.png"></a><span style="font-size:13.3px;font-family:arial,sans-serif"> </span><a href="http://twitter.com/#!/ronreiter" style="font-size:13.3px" target="_blank"><img width="16" height="16" alt="Twitter" style="padding:0px 0px 5px 0px;vertical-align:middle" border="0" src="http://images.wisestamp.com/twitter.png"></a><span style="font-size:13.3px;font-family:arial,sans-serif"> </span><a href="https://il.linkedin.com/in/ronreiter" style="font-size:13.3px" target="_blank"><img width="16" height="16" alt="LinkedIn" style="padding:0px 0px 5px 0px;vertical-align:middle" border="0" src="http://images.wisestamp.com/linkedin.png"></a></p></div></div></div></div></div></div></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Oct 21, 2018 at 10:20 PM Marko Ristin-Kaufmann <<a href="mailto:marko.ristin@gmail.com">marko.ristin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto">Hi,<div dir="auto">What about writing longer map&reduces in pyspark? When I worked with Spark and Scala, it was easy to script a longer chain of transformations in Scala. Does anybody know how that works in Python without multiline lambdas?</div><div dir="auto"><br></div><div dir="auto">Cheers Marko <br><div dir="auto"><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">Le dim. 21 oct. 2018 à 18:40, Ron Reiter <<a href="mailto:ron.reiter@gmail.com" rel="noreferrer" target="_blank">ron.reiter@gmail.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Multi-line lambdas may be nice for functional languages, but Python is very imperative in nature and prefers clean syntax over conciseness, which means it will make it REALLY hard to fit with Python. I personally find multi-line lambdas an unreadable abomination.</div><div><br></div><div>As for some more concrete reasons on why this should not be a part of Python, see here for an example which shows why it would even be hard to come up with a plausible syntax for multi-line lambdas:</div><div><a href="https://stackoverflow.com/questions/1233448/no-multiline-lambda-in-python-why-not" rel="noreferrer noreferrer" target="_blank">https://stackoverflow.com/questions/1233448/no-multiline-lambda-in-python-why-not</a><br></div><div><br></div><div>Guido's words:</div><div><br></div><div>"But the complexity of any proposed solution for this puzzle is immense, to me: it requires the parser (or more precisely, the lexer) to be able to switch back and forth between indent-sensitive and indent-insensitive modes, keeping a stack of previous modes and indentation level. Technically that can all be solved (there's already a stack of indentation levels that could be generalized). But none of that takes away my gut feeling that it is all an elaborate Rube Goldberg contraption."<br></div><div><br></div><div>If one would find a syntax which is Pythonic and clean then I am in favor of adding it, but I argue it simply does not exist.</div><br clear="all"><div><div dir="ltr" class="m_3597178427747667509m_1887944757376557327m_-589438871209136230gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><div style="margin:0px 0px 8px"><p style="margin:0px"><font size="2"><span style="font-family:arial,helvetica,sans-serif">- Ron</span><br></font></p><p style="font-size:13.3px;font-family:Verdana,Arial,Helvetica,sans-serif;margin:0px"><br></p><p style="font-size:13.3px;font-family:Verdana,Arial,Helvetica,sans-serif;margin:0px"><a href="http://www.facebook.com/ron.reiter" style="font-size:13.3px" rel="noreferrer noreferrer" target="_blank"><img width="16" height="16" alt="Facebook" style="padding:0px 0px 5px;vertical-align:middle" border="0" src="http://images.wisestamp.com/facebook.png"></a><span style="font-size:13.3px;font-family:arial,sans-serif"> </span><a href="http://twitter.com/#!/ronreiter" style="font-size:13.3px" rel="noreferrer noreferrer" target="_blank"><img width="16" height="16" alt="Twitter" style="padding:0px 0px 5px;vertical-align:middle" border="0" src="http://images.wisestamp.com/twitter.png"></a><span style="font-size:13.3px;font-family:arial,sans-serif"> </span><a href="https://il.linkedin.com/in/ronreiter" style="font-size:13.3px" rel="noreferrer noreferrer" target="_blank"><img width="16" height="16" alt="LinkedIn" style="padding:0px 0px 5px;vertical-align:middle" border="0" src="http://images.wisestamp.com/linkedin.png"></a></p></div></div></div></div></div></div></div></div></div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Oct 21, 2018 at 7:34 PM Anders Hovmöller <<a href="mailto:boxed@killingar.net" rel="noreferrer noreferrer" target="_blank">boxed@killingar.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div dir="ltr"></div><div dir="ltr"><br></div><blockquote type="cite"><div dir="ltr"><div dir="ltr"><div>Wheres a lambda expression can be passed anonymously to any other function as an argument.</div><div><br></div><div><i>map(lambda x: x**2, array)</i></div><div><br></div><div>vs </div><div><br></div><div><i>def powers2(x)</i></div><div><i> x**2</i></div><div><i>map(powers2, array)</i><br></div><div><br></div><div>Coming up with a name here is not needed, as the operation is expressive enough. </div></div>
</div></blockquote><br><div>Sure, but there is a well known convention for such non-names already: meta syntactical variables. In this case the name could be "foo" and all readers will interpret this as "no name". </div><div><br></div><div>I admit to have wanted lambdas that are just as powerful as normal functions, but often when I want it the code is nicer when a normal function is used. </div><div><br></div><div>/ Anders</div></div>_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" rel="noreferrer noreferrer" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" rel="noreferrer noreferrer" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer noreferrer noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer noreferrer noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div>
</blockquote></div>