Some language proposals.

Jacek Generowicz jacek.generowicz at cern.ch
Thu Feb 26 03:49:22 EST 2004


Paul Prescod <paul at prescod.net> writes:

> You've cleverly found one of the very few places where Python
> distinguishes between "true" functions and callable objects.

What bothers me more (I think, though I can't remember the exact
reasons why, right now, so maybe it's not that important), is that
Python distinguishes between "true" functions and "builtin" functions.

> I would argue that classes should distinguish between
> attributes-to-be-treated-as-methods and
> attributes-to-be-treated-as-just-attributes using something other than
> type.

Look again. They do. [Hint: descriptors]

> Consider the following program:
> 
> 
> class a:
>          pass
> 
> def func():
>          pass
> 
> lst = [1, 2, 3, "a", "b", "c", object(), lambda x:x ]
> 
> for x in lst:
>          a.b = x
>          assert a.b is x, "What???? %s"% x
>          print "Okay", x
> 
> Frankly I think it is unpythonic that a second after assignment to a.b
> the thing I get back is different than the thing I put in.

I do wish you'd run your examples through a Python interpreter before
posting them. The little bugs you include, really interfere with
trying to understand what your point is.

I suspect that what you are trying to demonstrate is this:

>>> for x in lst:
...     a.b = x
...     print a.b is x
... 
1
1
1
1
1
1
1
0

Though why you need 3 integers, and 3 strings, and a whole lot of line
noise to do it, escapes me.

[An I've stated in my followup to Michael, I have nothing else to say
about closures in Python.]



More information about the Python-list mailing list