This coding style bad practise?

Carl Friedrich Bolz cfbolz at gmx.de
Wed May 3 17:55:59 EDT 2006


Bruno Desthuilliers wrote:
> Martin P. Hellwig a écrit :
>>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

because that shadows a builtin?

sorry, could not resist :-)

Cheers,

Carl Friedrch Bolz




More information about the Python-list mailing list