Movatterモバイル変換


[0]ホーム

URL:


Import confusion

Kristian Ovaskakristian.ovaska at helsinki.fi
Sat Apr 7 10:59:33 EDT 2001


"Fredrik Lundh" <fredrik at pythonware.com>:>> Now, this prints 10. I'm confused. Could someone explain what's going>> on?>http://effbot.org/guides/import-confusion.htmI'm afraid this still isn't clear. Let's see. When I usefrom m2 import *,it imports x and setX, but x doesn't point to the same x that setXsees. There are two x's.I confirmed this by adding this method to m2 and calling it from m1:def printX():global xprint xIt prints 10, while "print x" still prints 0.>From your document:"from X import * imports the module X, and _creates references_ in thecurrent name space to all public symbols defined by that module"I underlined the part that confuses me. m1.x should be a reference tom2.x, no?-- Kristian Ovaska <kristian.ovaska at helsinki.fi>


More information about the Python-listmailing list

[8]ページ先頭

©2009-2025 Movatter.jp