need help with properties

Scott David Daniels Scott.Daniels at Acm.Org
Sat May 9 13:51:56 EDT 2009


Esmail wrote:
> Just curious, is there a way to pass more than one arg to a setter, or
> do we always have use some sort of unpacking at the other end?

Think about the source for a setter.  it comes from:
     <expr>.name = <expr>
You could add optional args, but the option would never be taken.
If you never intend to move to the 3.X versions of Python, you
code define the function as:

     def setter(self, (height, width)):
         ...

but since introspecting such things to give nice tracebacks and
good help messages drastically complicates the internal python
structure, and since the facility is so fraught with traps for
newbies, who might want to ask for, for example:
     def setter(self, (height=4, width=3)):

the Python 3.X world is wisely losing the unpacking in parameter
passing trick.

--Scott David Daniels
Scott.Daniels at Acm.Org




More information about the Python-list mailing list