Overloadable Assignment PEP

Anders J. Munch andersjm at inbound.dk
Thu Apr 3 21:35:35 CEST 2003


"Drew Moore" <drew at astro.pas.rochester.edu> wrote:
[...]
> voltage += 5  # (raise the voltage by 5 volts)
> voltage *= 2  # (double the current voltage)
>
> but when I do
>
> voltage = 3  # (set the voltage to 3 volts)
>
> my voltage object is clobbered with an integer object.
> I don't want to require the user to type any more than
> name = value # no name.val = newval, no name.setval(value)

How about
  name(value)

- Anders







More information about the Python-list mailing list