mardi 10 janvier 2017

Pylint tells me "import random" is either a redefining error or an undefined variable error.

I've got a problem with the import random which I don't fully understand.

Say I have got two functions in them same file. I use import random on both of them. Then I will get a console pylint error message telling me

Redefining name 'random' from outer scope (redefined-outer-name)

as well as

Reimport 'random' (reimported)

So naturally I try to use only one import random in the entire file, believing it will be valid. However, that will generate an error message of

Undefined variable 'random' (undefined-variable) since I've got undefined lines such as random.radintin one of the functions.

What would be the right way to tackle this occuring error? Should I use import random in every function I'm using random in, or should I somehow let the random "wrap" the entire file? How would I do that? It's driving me nuts and I think I don't fully understand the concept of random due to the mistakes I'm obviously making.

Thank you for helping.




Aucun commentaire:

Enregistrer un commentaire