Re[4]: Re: Mutable Bytes
Lenard Lindstrom <[email protected]> Fri, 30 Jul 2004 12:38:07 -0700 (Pacific Daylight Time)
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <Mahogany-0.66.0-4294835251-20040730-130544.00@pop3.norton.antivirus> |
On Fri, 30 Jul 2004 14:44:04 +1200 Greg Ewing <[email protected]> wrote: > > The function object also keeps a copy of the name, the doc string > > and the list of default argument values > > You're right, I had forgotten about those. > > Essentially, it holds all the stuff that can change from one > def execution to another, while the code object holds everything > that remains constant. > > The __doc__ attribute could also be implemented as a property > that looks up the __doc__ of the code object, if desired. > Actually, in Python the doc string is associated with the function object, not the code block. Python 2.4a1 (#54, Jul 8 2004, 11:30:13) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> def f(): ... "The doc string" ... pass ... >>> f.__doc__ 'The doc string' >>> f.func_code.__doc__ 'code(argcount, nlocals, stacksize, flags, codestring, constants, names,\n varnames, filename, name, firstlineno, lnotab[, freevars[, cellvars]])\n\nCreate a code object. Not for the faint of heart.' Lenard Lindstrom <[email protected]>