On Tue, Mar 9, 2010 at 9:18 AM, John Posner <jjpos...@optimum.net> wrote:
> 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 > > No. the name x will be bound to the same object. It's the other way that gives a problem from helpers import mostRecent works like import helpers mostRecent = helpers.mostRecent del helpers so when you do mostRecent = x it rebinds "mostRecent" in the current scope but doesn't affect helpers.mostRecent, the name in the "helpers" module. > -- > http://mail.python.org/mailman/listinfo/python-list >
-- http://mail.python.org/mailman/listinfo/python-list