properties access by name

Í

íÉÔÑ

I use rwproperty (http://pypi.python.org/pypi/rwproperty/1.0) and so I
have properties in my class. Also I have a list of names of properties
wich I am to set. How can I access my properties by name in such way
that when I want to set a property, setter will be called, and and
when I want to read it - getter?

I have something like this:

class Film(object):
def __init__(self, title):
self.__title = title

@getproperty
def title(self):
return self.__title
@setproperty
def title(self, value):
self.__title = value

properties_to_set = ['title']
f = Film('aaa')

I d want to have sth like:
f(properties_to_set[0]) = 'bbb'

If title was a simple variable I could write:
f.__dict__[properties_to_set[0]] = 'bbb'

now I can write:
f.__dict__['_Film__' + properties_to_set[0]] = 'bbb'

but I want to set my property through the provided setter. How can I
do this?

P.S. Sorry for my english
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top