title: Execute code on each node in PySpark
body: <p>I want to execute something on each node using PySpark, something like this:</p>
  
  <pre><code> rdd = sqlContext.read.parquet("...").rdd
   def f (i):
     import sys, socket
     return [(socket.gethostname(),sys.version)]
   vv = rdd.mapPartitions(f).collect()
  </code></pre>
  
  <p>but I don't see why I need to have to load a file for that.</p>
  
  <p>How do I do that?</p>