one-time factory in python for an experienced java guy

Paul Rubin http
Tue Jul 14 11:14:18 EDT 2009


phonky <phonky at europe.com> writes:
> "itertools.count(): Make an iterator that returns consecutive integers
> starting with n"
> 
> to me that sounds like that solves the increment issue, but what about
> future modules wanting to plug in a different
> numbering format, e.g. 205434.1234 or whatever?

You'd write a different generator for that, and use it instead of
itertools.count.  E.g. (untested):

  def different_gen():
      a  = 201593.0768                  # initial number
      while True:
         yield '%.04f'% a
         a += 123.4567                  # increase in increments of this much



More information about the Python-list mailing list