Comment on Draft Pep ver 4 -- Psuedo Deprecations of Builtins

Huaiyu Zhu huaiyu at gauss.almadan.ibm.com
Wed May 1 13:37:31 EDT 2002


Delaney, Timothy <tdelaney at avaya.com> wrote:
>> From: huaiyu at gauss.almadan.ibm.com 
>> 
>> John Roth <johnroth at ameritech.net> wrote:
>> >I strongly disagree about apply(). The only use I've found for it
>> >varies the function which it calls, not the parameter lists! Having
>> >variable parameter lists doesn't hack it - I need the variable
>> >function.
>> 
>> >>> from math import *
>> >>> a = (2.3,)
>> >>> for f in [sin, cos, sqrt]: print apply(f, a)
>> ... 
>> 0.745705212177
>> -0.66627602128
>> 1.51657508881
>> >>> for f in [sin, cos, sqrt]: print f(*a)
>> ... 
>> 0.745705212177
>> -0.66627602128
>> 1.51657508881
>
>There can be real advantages to apply being a first-class object though,
>which you don't get with the syntax f(*a, **b). apply can be passed around
>and used just as any callable.
>
>There is no way I would deprecate apply - esp. if you want code to work on
>1.5.2, 2.0, 2.1, 2.2, 2.3 without change (which is still possible for most
>code). I appreciate the f(*a, **b) syntax, but I think of it as an
>alternative to apply, not a replacement.

The example above was only meant to show that what John wanted can be
achieved without apply.  But of course apply does more than that.  And we
know that it's not going to be deprecated any way.  If there was a *real*
possibility that any of apply, filter, reduce ot map is going to be
deprecated there'd be far more protests than we saw.

Huaiyu



More information about the Python-list mailing list