[issue1388872] Polymorphic getters / setters

2009-06-30 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

This is normal behavior: the property is created with the functions
created just above, even before they belong to any class.

To make the property search the class hierarchy, you could write: 
  foo = property(lambda x: x.get_foo(), lambda x, v: x.set_foo(v))

or make it a function:
  def polymorphic_property(getter, setter):
  return property(lambda x  : getattr(x, getter)(),
  lambda x,v: getattr(x, setter)(v))
  [...]
  foo = polymorphic_property('get_foo', 'set_foo')

--
nosy: +amaury.forgeotdarc
resolution:  - works for me
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1388872
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1388872] Polymorphic getters / setters

2009-03-20 Thread Daniel Diniz

Daniel Diniz aja...@gmail.com added the comment:

Confirmed on trunk and py3k, not sure it's a bug.

--
nosy: +ajaksu2
priority: normal - low
versions: +Python 2.7, Python 3.1

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1388872
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com