[Python-Dev] Arbitrary attributes on funcs and methods

bwarsaw@cnri.reston.va.us bwarsaw@cnri.reston.va.us
Wed, 12 Apr 2000 14:43:01 -0400 (EDT)


>>>>> "SM" == Skip Montanaro <skip@mojam.com> writes:

    BAW> Floats don't currently have attributes.

    SM> True enough, but why can't they?

Skip, didn't you realize I was setting you up to ask that question? :)

I don't necessarily think other objects shouldn't have such
attributes, but I thought it might be easier to shove this one tiny
little pill down peoples' throats first.  Once they realize it tastes
good, /they'll/ want more :)
    
    SM> Awhile ago, Paul Prescod proposed something I think he called
    SM> a super tuple, which allowed you to address tuple elements
    SM> using attribute names:

    >> t = ("x": 1, "y": 2, "z": 3) print t.x
    |     1
    |     >>> print t[1]
    |     2

    SM> (or something like that).  I'm sure Paul or others will chime
    SM> in if they think it's relevant.

Might be.  I thought that was a cool idea too at the time.

    SM> Your observation was that functions have a __doc__ attribute
    SM> that is being abused in multiple, conflicting ways because
    SM> it's the only function attribute people have to play with.  I
    SM> have absolutely no quibble with that.  See:

    SM>
    SM> http://www.python.org/pipermail/doc-sig/1999-December/001671.html

    SM> (Note that it apparently fell on completely deaf ears... ;-) I
    SM> like your proposal.  I was just wondering out loud if it
    SM> should be more general.

Perhaps so.
-Barry