This coding style bad practise?
Bruno Desthuilliers
bdesth.quelquechose at free.quelquepart.fr
Wed May 3 20:28:12 EDT 2006
Martin P. Hellwig a écrit :
> 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?
Why not just use the call operator instead ? ie:
>>> id = IDGenerator(...)
>>> id()
01_20060424_151903_1
>>> id()
01_20060424_151905_2
More information about the Python-list
mailing list