[Tutor] PyMOTW: difflib

Dick Moores rdm at rcblue.com
Mon Apr 7 19:23:57 CEST 2008


At 12:23 AM 4/7/2008, Alan Gauld wrote:
>"Dick Moores" <rdm at rcblue.com> wrote in message
>
> > 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.
>
>import imports names. Any names, not just functions.
>After all, function names are just names like any other
>
>sqr = lambda x: x*x
>
>is exactly the same as
>
>def sqr(x): return x*x
>
>In both cases import will give you access to sqr as a name
>
>So in your case the names text1, text2, text1_lines and
>text2_lines will all be made available within your script.

I'm having trouble with the concept of a name in Python.

Is a name the same as anything defined? Such as

a, where a = 5
b, where b = [3,4,5]
c, where c = "Alan"
five(), where  def five(): return 5
sqr, where sqr = lambda x: x*x
square, where def sqr(x): return x*x

Are there other kinds of possibilities?
names of classes?
names of modules?

Dick


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



More information about the Tutor mailing list