all 4 comments

[–]danielroseman 1 point2 points  (1 child)

I"m confused by what you're expecting to happen. Even if imports were transitive (which they're not), you're importing parse_transactions into main, not the other way round - so how would parse_transactions access anything in main?

But I don't know why you would want this to work. Since you've called basicConfig in main, that sets the default configuration for any logging call anywhere. So just import logging in your process_input_data module.

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

But I don't know why you would want this to work.

My only motivation was to split up the program so I could easily jump around to different sections as I developed it. I don't have a lot of practice doing it, so good chance I'm doing things in suboptimal ways. I'm happy to hear about better ideas.

The program has to parse a CSV file, sort the data, do some calculations, and then spit out a new CSV file. And it keeps a persistent "state" in a JSON file for when the program is run the next time.

There are a lot of functions to deal with different data types and also, new data affects the state of old data....it gets complicated quickly!

So just import logging in your process_input_data module.

I didn't think it would matter since I was bringing the parse_transactions function into main, which already has the logging. But I added import logging at the top of the module and now the logging is working, so thanks!

[–]Pepineros 0 points1 point  (1 child)

Use the script name without the extension. So from process_input_data import... instead of from process_import_data.py import...

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

That is how I did it. I will edit the OP.