[Python-Dev] new property factory arguments (original) (raw)

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