c[:]()

Bruce Coram brucecoram at clara.co.uk
Sat Jun 2 04:10:14 EDT 2007


I am a relative newbie to Python and certainly to this mailing list.  I 
have watched this thread with interest.  After the first few exchanges I 
thought it would prove interesting and it has.

Warren Stringer is one of two things:

A joker having some fun at your expense.

An intellectually pretentious person who is so self absorbed that he is 
mentally incapable of seeing the hollowness of his ideas.

Either way it's probably not worth spending any more time on him.  All 
that needs to be said has been.  This thread is bare.

Exit

Bruce Coram
> 2007/6/1, Warren Stringer <warren at muse.com>:
>
>   
>> I am not insisting on anything. I use ``c[:]()`` as shorthand way of saying
>> "c() for c in d where d is a container"
>>
>> Having c() support containers seems obvious to me. It jibes with duck
>> typing. Perhaps the title of this thread should have been: "Why don't
>> containers quack?"
>>
>> A change is surprising only if it breaks something. I still haven't seen any
>> code that breaks by making such a change. Seeing such code would teach a
>> great deal.
>>     
>
> I think it very much bites duck typing. Currently, if I try to execute
> a string or a list or whatever, I get:
>
> TypeError: 'str' object is not callable
>
> But under your proposed semantics, suppose a is a list with some
> executable and some non-executable elements. What should
>
> a()
>
> now give? It cannot be a TypeError, because a list (in your semantics)
> is callable. Whatever error it gives, and whether or not the preceding
> executables are executed first, it will not be an existing error
> acting the way it normally does - there is no Python error for "you
> cannot do this with this object, but you can do it with other objects
> of the same type". And that does not seem to be a case of "We have
> never needed it yet" - the join method seems to have been specifically
> tailored so that no such error is needed.
>
>
>   





More information about the Python-list mailing list