Re: imported var not being updated



On 3/8/2010 11:55 PM, Gary Herron wrote:
<snip>

The form of import you are using
from helpers import mostRecent
makes a *new* binding to the value in the module that's doing the
import.

<snip>

What you can do, is not make a separate binding, but reach into the
helpers module to get the value there. Like this:

import helpers
print helpers.mostRecent


Gary, are you asserting that in these separate situations:

one.py:

from helpers import mostRecent
x = mostRecent

two.py:

import helpers
x = helpers.mostRecent


.... the name "x" will be bound to different objects?

Tx,
John
.



Relevant Pages

  • Re: imported var not being updated
    ... I have a project with many pyw files. ... The variable is "mostRecent", which is a string ... where output is a string and helpers has been imported. ...
    (comp.lang.python)
  • Re: imported var not being updated
    ... from helpers import mostRecent ... helpers module to get the value there. ... one = dict() ... If in doubt about namespaces, ...
    (comp.lang.python)
  • Re: imported var not being updated
    ... from helpers import mostRecent ... helpers module to get the value there. ... one = dict() ...
    (comp.lang.python)