one-time factory in python for an experienced java guy
Paul Rubin
http
Tue Jul 14 10:33:26 EDT 2009
Stefan Behnel <stefan_ml at behnel.de> writes:
> phonky wrote:
> > class Account(object):
> > def __init__(self, holder):
> > self.__accountnumber = self.__generate_account_number()
> >
> > Now, I do not know yet how the account number scheme looks like.
> > For now, I just want to have an incremental number; later,
> > when going to production, we'll need the proper one.
>
> Use a global variable in the module.
Yuch! Don't use a global. Try something like:
import itertools
class Account(object):
def __init__(self, holder, gen=itertools.count()):
self.__accountnumber = gen.next()
More information about the Python-list
mailing list