[Python-Dev] new property factory arguments

john coppola john_coppola_r_s@yahoo.com
Mon, 18 Feb 2002 06:20:28 -0800 (PST)


--- Jason Orendorff <jason@jorendorff.com> wrote:
> With minor changes, this works already.

> class Foo(property):
>     def __get__(self, container, _type=None):
> 	print "this is get"
> 	print "self:", self
 . . . 


I didn't subclass from property?  I do believe my with
example, any object new or old could be used as a
property.  And by looking at the code, property_init
clearly did not include GetAttr methods for __get__,
__set__, __del__.

If fact, there is not reason to include __delete__,
why not use __del__ instead?

If you send any ole python class instance to property
your code fails.  Thats the need for the change.

Without my patch...
class Bar(object): # <== object!
	def __get__(self,container,tp=None):
		print "get"
	def __set__(self,container,value):
		print "set"
	def __delete__(self,container):
		print "del"
		
>>> class Foo(object):
	x=property(Bar()) #performs coersion 
	
>>> a=Foo()
>>> a.x

Fails!
With my patch, it works.

Infact, I feel very strongly, that the old syntax
should be removed.  Better now then later. 
property(fget,fset,fdel,fdoc) does not make much sense
in the new object oriented world of python.


Sincerely,
John Coppola

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com