Property with Arguments

Lie Lie.1296 at gmail.com
Fri Jan 11 13:28:42 EST 2008


On Jan 11, 6:20 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> Lie wrote:
> > Is there a way to create a property with arguments?
>
> That's called method in Python, and has it's own syntax.  You cannot
> assign to methods.

So you've got to use methods? It was in VB.NET that I learned about
property with arguments, which is basically passing multiple values to
the property, one of which is considered the real value and the others
are metadata values. Now that I thought about it, I could use tuple to
pass multiple values... well there is a missing semantic concerning
which are real values and metadata values, but it doesn't really
matter.

>  > Or an index value like a list?
>
> Make the property that returns a list-like object (hooking __getitem__,
> __setitem__, etc).
>

well, I want to avoid creating an object or (worse) modifying existing
object, as the program I'm working on is very short and simple, and I
want to keep it that way.



More information about the Python-list mailing list