"Haoyu Bai" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | Hello, | | I'm a GSoC student working on SWIG's Python 3 support. When doing | experiment on Python 3's new features, the different behavior between | binding 'function' and 'builtin_function_or_method' confused me. | | As we know, unbound method is removed in Python 3. To bind a function to | a class, we can directly use this instead: | | MyClass.myfunc = func
That was always possible. | But in the case of builtin function, it can't work. What is it that 'cannot work'? My guess is that you are talking about the fact that instances do not get bound as an argument to the first parameter of a builtin. This is also true in 2.5.2 (for instance): >>> class T2(object): l=len ... >>> t2=T2() >>> t2.l() Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: len() takes exactly one argument (0 given) Your example with print did not throw an exception only because it allows no args. (And, it cannot work in 2.x where print is a statement keyword.) Or did you mean something else? If *extension* function show a difference, perhaps SWIG needs revision for 3.x. [Builtin callables are also different in respect to parameter naming and binding args by keyword. Perhaps to reduce confusion, they should not be named 'functions' in the manuals.] tjr _______________________________________________ Python-3000 mailing list Python-3000@python.org http://mail.python.org/mailman/listinfo/python-3000 Unsubscribe: http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com