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
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
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
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
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
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
>
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
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
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
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
>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
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):
12 matches
Mail list logo