@ehmatthes A very old Django project whose multiple settings files were importing from each other, leaving me very confused for a bit
I definitely would not recommend writing actual code that looks like this!
@ehmatthes A very old Django project whose multiple settings files were importing from each other, leaving me very confused for a bit
I definitely would not recommend writing actual code that looks like this!
@jonafato Interesting suggestion for a fix! What happens then if all the `from ... import *` are replaced by `from ... import A`?
@_chrismay I think you're on to something. In my mental model Python would only "cache" an import after it's complete, but that doesn't appear correct.
Bonus questions for you then, what if `a.py` contains this: `A = 1; from b import *; A+=1`?
Or even this `A = 1; from b import *; A+=1;from b import *` ?
@treyhunner Tagging you on this since it might qualify as a #Pythonoddity
@alexgmin Try it and see, then please explain the result to me, I genuinely don't understand what's going on
Can someone explain this #Python import behavior?
I'm in a directory with 3 files:
a.py contains `A = 1; from b import *`
b.py contains `from a import *; A += 1`
c.py contains `from a import A; print(A)`
Can you guess and explain what happens when you run `python c.py`?