Suggesting for overloading the assign operator

John Roth johnroth at
Tue Jul 1 18:44:02 CEST 2003

"Rim" <rimbalaya at> wrote in message
news:6f03c4a5.0306301931.3f15fbb7 at
> Hi,
> I have been thinking about how to overload the assign operation '='.
> In many cases, I wanted to provide users of my packages a natural
> interface to the extended built-in types I created for them, but the
> assign operator is always forcing them to "type cast" or coerce the
> result when they do a simple assign for the purpose of setting the
> value of a variable.

Use a property. Changing the semantics of the assignment
statement (NOT assignment operator) is not going to happen.

Properties are new in Python 2.2 (which is around a year
old by now.) They enable you to have getter and setter
methods with an interface that looks like an instance

John Roth

More information about the Python-list mailing list