Movatterモバイル変換
[0]ホーム
function pointers
Erik Max Francismax at alcyone.com
Thu Apr 26 11:39:05 EDT 2001
Courageous wrote:> Not only does it have function pointer equivalents, it does things> that even> C, C++, and Java can't. For example:>> >>> class MyClass:> def f(self):> print "amazing">>> >>> m = MyClass()> >>> f = m.f> >>> f()> amazing> >>>>> You can't do that in C++ or Java!>> It's very cool.Indeed, being able to move around bound methods is one of the thingsthat impressed me most about Python. Often you want a simple callbackmechanism, but if you're fiddling with methods and can only shufflearound references to unbound methods, this makes things less pleasant. Guido either had the foresight or experience (or both) to realize thatbound methods are fantastically useful -- they're something thatlanguage writers tend to realize would be a great addition ... too late.-- Erik Max Francis /max at alcyone.com /http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE/ \ Love is the wisdom of the fool and the folly of the wise.\__/ Samuel Johnson blackgirl international /http://www.blackgirl.org/ The Internet resource for black women.
More information about the Python-listmailing list
[8]ページ先頭