Ayush Anand
Ayush Anand

Reputation: 21

Python module "filename" has no attribute "variable"?

I have a file o.py in which I am importing v.py

**o.py**   **v.py**

import v    `lr=2`
t=v.lr

Inside v.py i am storing some values inside a variable lr but when I am running o.py attribute error is coming that module v has no attribute lr even though I have used lr variable inside v.py. help?

Upvotes: 0

Views: 120

Answers (1)

I have tested the code and it should work.

Please ensure that the v.py only contains

lr=2

and not

`lr=2`

Also please ensure that o.py and v.py are in the same directory.

Please also give more attention to your variable and file naming. Understanding one letter variables and file names is difficult. Take the time to name your variables and file names properly to improve maintainability.

Here is some reading material on naming: https://techietweak.wordpress.com/2018/03/10/naming-conventions-from-uncle-bobs-clean-code-philosophy/

Upvotes: 3

Related Questions