[Python-projects] return statement in __init__

Sylvain Thénault Sylvain.Thenault at logilab.fr
Mon Apr 18 09:46:48 CEST 2005


On Friday 15 April à 22:17, logilab.abcx at spamgourmet.com wrote:
> PyLint of the attached file:
> 
> E0101 init_return LegalConstructor1.__init__ 3 Explicit return in __init__
> E0101 init_return LegalConstructor2.__init__ 8 Explicit return in __init__ 
> E0101 init_return IlegalConstructor.__init__ 13 Explicit return in __init__ 
> E0101 init_return LegalConstructorOld1.__init__ 18 Explicit return in __init__ 
> E0101 init_return LegalConstructorOld2.__init__ 23 Explicit return in __init__ 
> E0101 init_return IlegalConstructorOld.__init__ 28 Explicit return in __init__ 
> 
> This error should be reported only for the IlegalConstructor classes
> since it's legal to return None or just return from a constructor.

IMHO it's a bad habit to have a return in __init__, valid or not valid.
Maybe should I turn the error into a warning when it's a "legal" return,
but I'm really not sure here. 

-- 
Sylvain Thénault                               LOGILAB, Paris (France).

http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org



More information about the Python-Projects mailing list