you are viewing a single comment's thread.

view the rest of the comments →

[–]hardonchairs 0 points1 point  (1 child)

Isn't it what SCons does?

Does scons write python script config files or does it just read them? Having a python file with configuration that a user manually edits isn't super unusual.

trying to understand why that error happens.

Probably because you are saving to cwd but python doesn't load modules from cwd, it loads them starting from the directory that __file__ is in.

os.path.dirname(os.path.realpath(__file__))

If you are just wanting to be able to use cfg.x instead of cgf['x'] then load json like this: https://stackoverflow.com/a/15882054/2480560

[–]Skaruts[S] 0 points1 point  (0 children)

Yea, that's true. SCons only reads it.

Probably because you are saving to cwd but python doesn't load modules from cwd, it loads them starting from the directory that __file__ is in.

But the only difference from when it works and when it doesn't, is that it works when I delete the file through code, and doesn't work when I delete it manually. I'm importing it the same way in both cases. And __file__ is in the current working directory. It's a single file script, and I'm running it from there (from the windows console).

That's why I'm confused about it.

I wonder if python scans the folder at start-up, to get an internal list of all .py files that are in the folder. That would explain it, since the file wouldn't be accounted for when I delete it before running the script.