Property type hints?

dn PythonList at DancesWithMice.info
Thu Dec 10 01:13:08 EST 2020


On 10/12/2020 13:06, Paul Bryan wrote:
> Thanks for the comprehensive response, dn!
> 
> I guess I'm influenced by data classes here, where the object's 
> attribute type hints are represented by class variable annotations.


I'm a great fan of them too - the saving of 'boilerplate code' does it 
for me; but yes, the typing benefits come for-free!


Just in case it needs to be said: there's no need to 'declare' 
properties (or any other methods) as if they are class-attributes - 
either when using data-classes or rolling-your-own!

Also, remember that class-attributes will become (actually be 'hidden' 
by) instance-attributes if used on the LHS of an expression within the 
class (replicating the 'two' entity problem, discussed earlier).
-- 
Regards =dn


More information about the Python-list mailing list