[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-list
Subject:    Re: built-in 'property'
From:       Shalabh Chaturvedi <shalabh () cafepy ! com>
Date:       2004-12-28 1:11:21
Message-ID: 41D0B2B9.1090702 () cafepy ! com
[Download RAW message or body]

Bob.Cowdery@CGI-Europe.com wrote:
> 
> Hi
>  
> Can any one explain how property works. It seems to be fine if executed 
> on import i.e. if the property statement is at class scope. 

Properties are meant to be used at the class scope. A property is a kind 
of descriptor. See http://users.rcn.com/python/download/Descriptor.htm 
for details of descriptors.


> If I put the 
> statement inside __init__() then it appears to work ok but when I try to 
> access the property by e.g. klass.x it just tells me it is a property 
> object.

Please show us the code of what you are doing and describe what you are 
trying to do. There are a lot many things one could do with a property 
in __init__(). Mostly properties are just defined at the class scope. 
And rarely would you access klass.x (where x is a property object), 
mostly you would do instance.x.

> Is this statement only designed to work at class scope? I really 
> want to set these properties per instance.

Again, what exactly are you trying to do? The link above has some simple 
examples of how to use properties.

--
Shalabh

-- 
http://mail.python.org/mailman/listinfo/python-list
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic