At 04:39 PM 4/6/2008, Alan Gauld wrote:

"Dick Moores" <[EMAIL PROTECTED]> wrote
>> > Copied the data into my demo_pymotw-difflib.py,
>> > deleted the line "from difflib_data import *",
>> > and ran it
>>
>>I'm curious. Why did you do that?

> OK, I put it back in, changing the filename to
> demo_pymotw-difflib_error.py.
> See < http://py77.python.pastebin.com/f5c3a37ce> for the code and the
> ImportError: No module named difflib_data.

You still have the copied data which will overwrite the values
imported however to import it you need to have the path set
up correctly. Is the difflib_data.py in the same folder as difflib.py?

No. The paths are E:\PythonWork\PyMOTW-1.48\difflib\difflib_data.py
and E:\Python25\Lib\difflib.py

Even if there weren't a path problem, my understanding is that   from difflib_data import *   would only import the functions in difflib_data.py; There are none.  See difflib_data.py at < http://py77.python.pastebin.com/f5e2c73a5>. Am I wrong?

Ah ha! I AM wrong, aren't I. I just realized that Hellman's intention was to run difflib_differ.py (< http://py77.python.pastebin.com/f7853ef8>), which IS in the same folder, difflib, as difflib_data.py.  Works fine.  I didn't need to make my own script.

I'm still puzzled, though. How can   from difflib_data import *   work? 

Let's see. Say I have a script, some_variables.py

===========some_variables.py=============
#!/usr/bin/env python
a = 1
b = 2
c = 3
=========end of some_variables.py========

And a script, importer.py

=========importer.py=====================
#!/usr/bin/env python
from some_variables.py import *
print a, b, c, a*b*c
========end of importer.py===============

And by golly, I do get
> "E:\Python25\pythonw.exe" -u "E:\PythonWork\importer.py"
1 2 3 6

Sorry, folks, but I'm truly amazed. How come I didn't know this before??

Thanks, Alan, you've opened my eyes.

Dick

           ================================
UliPad <<The Python Editor>>: http://code.google.com/p/ulipad/

_______________________________________________
Tutor maillist  -  [email protected]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to