This coding style bad practise?

bruno at modulix onurb at xiludom.gro
Thu May 4 04:26:02 EDT 2006


Carl Friedrich Bolz wrote:
> 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?

oops :(

> sorry, could not resist :-)

<op>
idgen = IDGenerator(...)
idgen()



-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list