one-time factory in python for an experienced java guy
mabdelkader at gmail.com
Tue Jul 14 11:07:59 EDT 2009
What Paul was trying to elaborate on is that have your customers or whomever
will use this implement their own generator protocol to generate whatever
number format they need. Paul just gave you an example with
itertools.count(), where it is an infinite generator that yields count+1
Read up on the iterator protocol, have your customers pass in a generator to
establish their own formats.
This is much more elegant than AbstractCustomerRandomFormatGenerator..etc
which is what the reference to "erase everything from Java" is attempting to
mahmoud mack abdelkader
mahmoud at linux.com
On Tue, Jul 14, 2009 at 10:55 AM, phonky <phonky at europe.com> wrote:
> Thanks Paul,
> Ugh, just forget everything you ever knew about java. Do some Zen
>> exercises to erase your mind. Then read a Python tutorial as if
>> you're starting from nothing.
> Yeah, surely right, but easier said than done...
> I'm working on it.
> Taking your example.
> import itertools
> class Account(object):
> def __init__(self, holder, gen=itertools.count()):
> self.__accountnumber = gen.next()
> If you consider my python illiteracy,
> "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?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list