Overloadable Assignment PEP

Ben Hutchings do-not-spam-ben.hutchings at businesswebsoftware.com
Fri Apr 4 12:00:16 EST 2003


In article <b6j711$5m5dh$2 at ID-169208.news.dfncis.de>,
Greg Ewing (using news.cis.dfn.de) wrote:
> Drew Moore wrote:
>> # modify the voltages, in a very simple, readable syntax.
>> vdduc = -3.8 # try a reduced supply
>> vreset = -3.2 # and increased reset drive...
>> vbias = 2.3 # and decreas the bias a little..
> 
> Maybe our brains work differently, but I'd find it
> FAR less confusing if the dac were an object and
> one did
> 
>    dac.vdduc = -3.8
>    dac.vreset = -3.2
>    dac.vbias = 2.3

I implemented a change to Python that would let you access
attributes of a 'default' object without naming it.  The default
object would be a 'for' loop's iterator (if a simple variable)
or the function's first argument.  This would let you (ab)use a
'for' statement as something like VB's 'with' statement:

    for dac in [dac]:
        .vdduc = -3.8
        .vreset = -3.2
        .vbias = 2.3
        
It would also let you omit many uses of 'self' in a method.

Whether that's desirable or whether I could release that, I do
not know.




More information about the Python-list mailing list