The following code only prints "good". Why the generator function is not executed?
I noticed with pdb that after executing 'handlers1' the script reaches the line with f1's definition but then does not get inside the function. Conversely, it's returned 'GeneratorExit: None'.

class foo:

   def f0(self, s):
      print s

   def f1(self, s):
      print "not " + s
      yield 1

   def run(self):
      handlers={0 : self.f0, 1 : self.f1}
      handlers[0]('good')
      handlers[1]('good')

bar = foo()
bar.run()


Why this happens? Is it possible to call generator functions in a similar dynamic way?


Question: Creating DotPlots
Answer: It is a Chart so one may want to use BarChart:

(* speakers are stored with [people] units so we have to get rid of it, 
   I'm also deleting Malavian since there is no data now*)
sorted = MapAt[QuantityMagnitude, #, {2}] &amp; /@SortBy[data, #[[2]] &amp;] // Rest
len = Length[sorted]

mark[{{xmin_, xmax_}, {ymin_, ymax_}}, ___] := {Black, AbsolutePointSize@7, 
                                              Point[{Scaled[{0, -.02}, {xmax, ymax}]}]}
topt = Table[{i, 2^i}, {i, 0, 9}];

BarChart[Log[2, sorted[[ ;; , 2]]/10^6], 
         ChartLabels -&gt; sorted[[ ;; , 1]], BarOrigin -&gt; Left, BarSpacing -&gt; Large, 
         GridLines -&gt; {None, Range@len}, GridLinesStyle -&gt; Dotted, 
         ChartElementFunction -&gt; mark, Frame -&gt; {{False, True}, {True, True}},
         AxesOrigin -&gt; {0, -1}, FrameTicks -&gt; {{False, False}, {Automatic, topt}}]