[code-quality] Bad coding style?

Mark Shannon mark at semmle.com
Sat Feb 8 14:05:04 CET 2014


On 06/02/14 18:51, Thomas Heller wrote:
> I sometimes have code like this:
>
> class Foo:
>
>      def spam(self):
>          ....
>
>      from somewhere import method
>      from somewhere import CONSTANT
>
>      def blah(self):
>          ....
>
> where CONSTANT defines a class attribute, anbd method
> is a method that I would like to call like any other
> methor (self.spam(), or self.blah()).
>
> This works nicely and is a compact coding style, however
> frosted complains about unused imports.
frosted is wrong here as CONSTANT is used to build the locals() dictionary
used to build the class Foo

>
> Should I fix my coding habits, or should frosted by fixed?
Both ;)
Don't forget "Readability counts".

Cheers,
Mark.


More information about the code-quality mailing list