Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Property error

2006-12-15 Thread George Sakkis
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > def

Re: Property error

2006-12-15 Thread Peter Otten
Peter Otten wrote: > @decorator > def f(): > # ... > > is the same as > > def f(): > # ... > f = decorator(f()) > > What happens when your age() function is invoked? There is no explicit > return statement, so None is implicitly returned, and > > age = property(age()) > > is the same as age

Re: Property error

2006-12-15 Thread Georg Brandl
king kikapu wrote: > Hi to all, > > i am trying to use properties in Python and i am sure i have made > something wrong with the below code but i just cannot see what it is. > > Can anyone please help me on this ? > > The code is : > > class Person(object): > age = 0 > > @property >

Re: Property error

2006-12-15 Thread Rob Williscroft
king kikapu wrote in news:1166181267.949316.197360@ 16g2000cwy.googlegroups.com in comp.lang.python: > I am sure it is something very obvious Yes, property is *NOT* a decorator, it can only be used as a decorator in the one case that is mentioned in the docs: http://docs.python.org/lib/built-in

Re: Property error

2006-12-15 Thread Georg Brandl
Peter Otten wrote: > @decorator > def f(): ># ... > > is the same as > > def f(): > # ... > f = decorator(f()) ^^ Nope, f is not called here. (Think of staticmethod). Georg -- http://mail.python.org/mailman/listinfo/python-list

Re: Property error

2006-12-15 Thread Peter Otten
king kikapu wrote: > Your example Dennis, work as expected. I understand the mistake i have > made. But when i try to fix the original code usihn @property now, it > gives me the same error. > So, here it is: > > class Person(object): > _age = 0 > > @property > def age(): > d

Re: Property error

2006-12-15 Thread king kikapu
Your example Dennis, work as expected. I understand the mistake i have made. But when i try to fix the original code usihn @property now, it gives me the same error. So, here it is: class Person(object): _age = 0 @property def age(): def fget(self): return self._a

Re: Property error

2006-12-15 Thread king kikapu
>What version of Python? Most recent versions don't need the Hi, thanks for the help! I am using 2.5 version and i think i like more the @property decorator instead of the property(...) syntax. Is the code changing much using @property ?? Thanks again! -- http://mail.python.org/mailman/lis

Property error

2006-12-14 Thread king kikapu
Hi to all, i am trying to use properties in Python and i am sure i have made something wrong with the below code but i just cannot see what it is. Can anyone please help me on this ? The code is : class Person(object): age = 0 @property def age(): def fget(self):