Tkinter bug ?
Fredrik Lundh
fredrik at pythonware.com
Mon Jul 26 13:28:13 EDT 1999
More information about the Python-list mailing list
Mon Jul 26 13:28:13 EDT 1999
- Previous message (by thread): Tkinter bug ?
- Next message (by thread): Python GUI
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Stephane Conversy <conversy at lri.fr> wrote: > ok, but does it have something to do with the fact that in one case > I do a from file1 import * and in the other import file1 ? now that you mention it... forget my previous answer (for the moment; you might stumble upon that problem later). ... if you'd added some "print photo" statements to File2.py in your first example, you would have noticed that the variable is None both before and after the call to create_photo(). if you'd added similar statements to File1.py, you would have noticed that create_photo actually did set it to something else. the reason for this is that all variables in Python contain references to objects, not the objects themselves. the assignment statement just changes a variable to refer to a new value, it doesn't copy the object itself (nor does this modify the old value). and import is just a fancy assignment statement; the from-import form copies object references from the imported module, not the objects itself. in other words, after the import, there are TWO "photo" variables, one in each module. and changing one to refer to a new object doesn't automatically change the other one. > I'm a beginner in Python, and don't know exaclty how modules > are implemented... but in that case, you shouldn't be using from-import at all ! for more details, see: http://www.pythonware.com/people/fredrik/fyi/fyi06.htm note the fourth item under "Which Way Should I Use?" ;-) </F>
- Previous message (by thread): Tkinter bug ?
- Next message (by thread): Python GUI
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list