"Roy Smith" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | There is a fundamental disharmony in how functions and other objects are | treated in Python. [snip]
For scalars and collections, print object prints the value, which is the main part of the object, in a form close to (or equal to) how it is created in code. For functions, classes, and modules, this would be awkward to impossible since the corresponding code is not part of the object and may be either bulky and slow to access, not accessible, or non-existent. So these three get name attitributes as a substitute. Function names are also used to improve tracebacks over 'function at line nnn'. Perhaps for these types, print could (should?) instead print the first list of the doc string, if there is one. Method objects inherit the name of the function they wrap. Other internal types are left anonymous, but how could they get a name when there is no code to give them a name. Yes, fundamentally different categories of types are (sensibly) treated differently with repect to definition and namespace names, but calling that 'disharmony' depends on the listener. | If we created lisp-like lambdas and bound them to names like we did with | other types of objects, we wouldn't have that. Correct. Tracebacks would always instead of just occasionally be less useful as functions would always be identified only by file and line number, as today with lambda expression. Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list