Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

bmispelon@mastodon.socialB

bmispelon@mastodon.social

@bmispelon@mastodon.social
About
Posts
6
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

View Original

Posts

Recent Best Controversial

  • Can someone explain this #Python import behavior
    bmispelon@mastodon.socialB bmispelon@mastodon.social

    @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!

    Uncategorized python

  • Can someone explain this #Python import behavior
    bmispelon@mastodon.socialB bmispelon@mastodon.social

    @jonafato Interesting suggestion for a fix! What happens then if all the `from ... import *` are replaced by `from ... import A`?

    Uncategorized python

  • Can someone explain this #Python import behavior
    bmispelon@mastodon.socialB bmispelon@mastodon.social

    @_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 *` ?

    Uncategorized python

  • Can someone explain this #Python import behavior
    bmispelon@mastodon.socialB bmispelon@mastodon.social

    @treyhunner Tagging you on this since it might qualify as a #Pythonoddity

    Uncategorized python

  • Can someone explain this #Python import behavior
    bmispelon@mastodon.socialB bmispelon@mastodon.social

    @alexgmin Try it and see, then please explain the result to me, I genuinely don't understand what's going on

    Uncategorized python

  • Can someone explain this #Python import behavior
    bmispelon@mastodon.socialB bmispelon@mastodon.social

    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`?

    Uncategorized python
  • Login

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups