Thank you. Problem solved.
/Adam
On Sun, May 05, 2013 at 06:27:44PM +0100, Fábio Santos wrote:
> That assert will never fail. If the symbol is not imported, the import
> statement raises ImportError. And actually "assert" makes sure that
> the value is not false-ish, not None/Null. And AFAIK a mod
That assert will never fail. If the symbol is not imported, the import
statement raises ImportError. And actually "assert" makes sure that
the value is not false-ish, not None/Null. And AFAIK a module object
is *always* true.
> One more question. In this particular case it seems 'assert' should be
Thanks. It works very well.
One more question. In this particular case it seems 'assert' should be
safe as a workaround, doesn't it? 'assert' will check if the symbol
is imported and not NULL. Is there side effect if I just applied this
rule as a generic one.
/Adam
On Sun, May 05, 2013 at 05:18:
Adam Jiang wrote:
> I am new to python. Now, I am woring on an application within Django
> framework. When I checked my code with pep8 and pyflakes, some warning
> messages show up-'Foobar imported but unused'. Obviously, it indicates
> that some modules are imprted to current module but never get
On 05/05/2013 17:00, Adam Jiang wrote:
I am new to python. Now, I am woring on an application within Django
framework. When I checked my code with pep8 and pyflakes, some warning
messages show up-'Foobar imported but unused'. Obviously, it indicates
that some modules are imprted to current module
I usually do this on pyflakes:
import whatever
assert whatever # silence pyflakes
Pyflakes and pep8 have no way of knowing django will import and use your
module, or whether you are just importing a module for the side effects, so
they issue a warning anyway. Assert'ing counts as using the modul