title: How to output singleton pvalue to console in Beam?
body: <p>I try to output the result <code>spammers_view</code> of <code>as_singleton_view()</code> to console, per <a href="https://github.com/apache/beam/blob/master/sdks/python/apache_beam/examples/complete/game/game_stats.py#L334" rel="nofollow noreferrer">codes</a></p>
  
  <pre class="lang-py prettyprint-override"><code>    # Calculate the total score per user over fixed windows, and cumulative
      # updates for late data
      spammers_view = (
          user_events
          | 'UserFixedWindows' &gt;&gt; beam.WindowInto(
              beam.window.FixedWindows(fixed_window_duration))
  
          # Filter out everyone but those with (SCORE_WEIGHT * avg) clickrate.
          # These might be robots/spammers.
          | 'CalculateSpammyUsers' &gt;&gt; CalculateSpammyUsers()
  
          # Derive a view from the collection of spammer users. It will be used as
          # a side input in calculating the team score sums, below
          | 'CreateSpammersView' &gt;&gt; beam.CombineGlobally(
              beam.combiners.ToDictCombineFn()).as_singleton_view())
  </code></pre>
  
  <p>what I have tried</p>
  
  <p>1st try</p>
  
  <pre class="lang-py prettyprint-override"><code>          | 'debug_output' &gt;&gt; beam.Map(debug_collect)
  
      ...
      def debug_print(row):
         print(row)
  </code></pre>
  
  <p>2nd try</p>
  
  <pre class="lang-py prettyprint-override"><code>
        (spammers_view | 'debug_print' &gt;&gt; PrintTran())
  
  class PrintTran(beam.PTransform):
      def expand(self, data):
          print(pvalue.AsIteor(data))
  </code></pre>
  
  <p>However, the following exception comes up</p>
  
  <pre><code>  File "/usr/local/lib/python2.7/site-packages/apache_beam/transforms/ptransform.py", line 896, in __ror__
      return self.transform.__ror__(pvalueish, self.label)
    File "/usr/local/lib/python2.7/site-packages/apache_beam/transforms/ptransform.py", line 506, in __ror__
      for ix, v in enumerate(pvalues)
    File "/usr/local/lib/python2.7/site-packages/apache_beam/transforms/ptransform.py", line 507, in &lt;dictcomp&gt;
      if not isinstance(v, pvalue.PValue) and v is not None}
    File "/usr/local/lib/python2.7/site-packages/apache_beam/transforms/core.py", line 2213, in __init__
      self.values = tuple(values)
  TypeError: 'AsSingleton' object is not iterable
  </code></pre>
  
  <p>Beam version: 2.14.0</p>
  
  <p>How to output singleton value to console in Beam?</p>