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

ehmatthes@fosstodon.orgE

ehmatthes@fosstodon.org

@ehmatthes@fosstodon.org
About
Posts
5
Topics
0
Shares
0
Groups
0
Followers
0
Following
0

View Original

Posts

Recent Best Controversial

  • Can someone explain this #Python import behavior
    ehmatthes@fosstodon.orgE ehmatthes@fosstodon.org

    @bmispelon

    > whose multiple settings files were importing from each other

    You are not the only one who would be confused, please do not mention this in office hours

    Uncategorized python

  • Can someone explain this #Python import behavior
    ehmatthes@fosstodon.orgE ehmatthes@fosstodon.org

    @bmispelon Can you share the real-world motivation for this question at some point?

    Uncategorized python

  • Can someone explain this #Python import behavior
    ehmatthes@fosstodon.orgE ehmatthes@fosstodon.org

    @bmispelon Here's my VSCodium session:

    Uncategorized python

  • Can someone explain this #Python import behavior
    ehmatthes@fosstodon.orgE ehmatthes@fosstodon.org

    @bmispelon Then I ran c.py in a VS Codium debugger session, watching A.

    - A starts as undefined (everything does).
    - After the first line of a.py, A is 1, but I think that VS Codium is actually reporting a.A.
    - The import in a is hit, and A goes to undefined. I think VSC is showing b.A.
    - b's import runs, and A is 1. I think that's b.A.
    - The second line of b is run, and A is 2.
    - Execution goes back to c, where the value of A is 2.

    Uncategorized python

  • Can someone explain this #Python import behavior
    ehmatthes@fosstodon.orgE ehmatthes@fosstodon.org

    @bmispelon My initial guess was 2. c first imports a.A, which is 1. But the call to import from a loads a.py. That includes the call to import * from b, which imports from a. So at that point, A is 1. b then adds one to A, which sets A at 2. Then execution returns to c, with A at 2. So I think the value of A in c comes from b.

    I tried to verify this in a pdb session, but stepping through at a low enough level to see this was bringing me into even lower level Python functions.

    Uncategorized python
  • Login

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