Movatterモバイル変換
[0]ホーム
[Python-Dev] PEP 309: Partial method application
Nick Coghlanncoghlan at gmail.com
Fri Aug 19 00:43:06 CEST 2005
Brett Cannon wrote:>>>What I think you want is not a partial method, instead, you want to>>>turn a method into a standard function, and in a 'virtual' way.>>>>>>So I would propose the syntax>>>>>> lst.sort(key=virtual.lower) # where virtual is functional.virtual>>>>I like this, but would hope for a different name -- the poor word>>'virtual' has been abused enough by C++.>> Yeah, me too. Possible name are 'delayed', 'lazyattr', or just plain> 'lazy' since it reminds me of Haskell.Hmm, "methodcall"?As in: lst.sort(key=methodcall.lower)Where "methodcall" is something like what Shane described: class methodcall: def __getattr__(self, name): def delayedcall(*args, **kwds): return getattr(args[0], name)(*args[1:], **kwds) return delayedcall methodcall = methodcall()>> Oh, when should we think of putting reduce into functional? I> remember this was discussed when it was realized reduce was the only> functional built-in that is not covered by itertools or listcomps.I expected functional.map, functional.filter and functional.reduce to all exist in 2.5.Cheers,Nick.-- Nick Coghlan |ncoghlan at gmail.com | Brisbane, Australia---------------------------------------------------------------http://boredomandlaziness.blogspot.com
More information about the Python-Devmailing list
[8]ページ先頭