help on "from deen import *" vs. "import deen"

jfong at ms4.hinet.net jfong at ms4.hinet.net
Mon Nov 14 20:36:47 EST 2016


Ned Batchelder at 2016/11/15 6:33:54AM wrote:
> > But I get a wrong answer this way:
> > >>> from deen import *
> > >>> tblm = tbli
> > >>> gpa(0x7d)
> > 125  # it's 0x7d, the tblm[2] is 0
> > 
> > Why? why! why:-(
> 
> Here you are assigning a value to your own tblm, not deen.tblm,
> so gpa does not see the new value.
> 
Hi Ned, below is the capture of my terminal screen:

D:\Temp>python
Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 19:28:18) [MSC v.1600 32 bit (In
tel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> dir()
['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__']

>>> from deen import *
>>> dir()
['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__',
 'gpa', 'tbli', 'tblm']
>>> tblm
[0, 0, 0]
>>> tblm=tbli
>>> tblm
[102, 39, 208]
>>> dir()
['__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__',
 'gpa', 'tbli', 'tblm']
>>>

Do you mean the last 'tblm' is my own? How it can be? The 'tblm' already exist before the assignment and this assignment shouldn't create a new one, right? and how do I assign the 'deen.tblm' under this circumstance?

--Jach




More information about the Python-list mailing list