keirr wrote: > Martin P. Hellwig wrote: >> Hi all, >> >> I created a class which creates a relative unique id string, now my >> program just works fine and as expected but somehow I get the feeling >> that I misused the __repr__ since I guess people expect to 'execute' a >> function in an instance instead of using it's representation string of >> the instance itself, could you elaborate whether you find this bad >> practice and if yes what would have been a better way to do it? >> >> TIA >> > > Rather than comment on the style of using a class, I'll just suggest an > alternative. > You can use a generator function, which yields the next id when called; > at least that's > how I'd implement an IDgenerator. > > Cheers, > > Keir. >
Thanks for your comment, I do use a generator in my class because I wanted to wrap my subversion when its on its end I had a choice of looping in with an if check or using a generator with try except, this time I choose a generator, though mostly I directly use a generator for these type of functions. -- mph -- http://mail.python.org/mailman/listinfo/python-list