function attributes are like function objects

Fredrik Lundh fredrik at effbot.org
Sat Feb 3 09:36:07 EST 2001


Christian Tanzer wrote:
> > and I doubt many people would notice if __doc__ were made
> > readonly...
>
> Well, I'm not many but I certainly would notice (and complain, too).

Did you read the language specification before you started
abusing the __doc__ attribute?  If you look under function
objects, you'll notice that it says that the __doc__ attribute
MAY be writable.  Not that it always will be.

(the real reason to have writable func_doc/func_code attributes
is to allow a development environment to update functions in a
running program, not so much to support doc-string hacks in user
code).

And if you're relying on implementation-dependent features, you
only have yourself to blame...

> Worse, it is a FORTRANique [*] instead of a
> pythonic solution.

Really?  I didn't know Fortran had builtin dictionaries and hashable
function objects, or that it builds class objects by executing code
in a special namespace...

> For a single method attribute, it doesn't matter much but if several
> attributes are used per method it sucks.

Yeah, right -- we all know that writing two lines instead of
two lines suck...

</F>





More information about the Python-list mailing list