In python, every(?) variable name and its value is stored in a dict
somewhere, and when you try to access the name, it is looked up in the
dict.  So if you write:

def f(x):
    print x
def f(x, y):
    print x,y

when those lines are first parsed as your file loads, somewhere this
happens:

somedict = {}
somedict["f"] = fx
somedict["f"] = fxy

which has the same effect as:

d = {}
d["a"] = 10
d["a"] = "hello"
print d["a"]

--output:--
"hello"


So the second value for "f" overwrites the first value.  Then when you
call f(...), the name "f" is looked up in the dict, and the
corresponding value is returned.  In this case, that would be a
reference to the second function f(x,y).

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to