properties and formatting with self.__dict__

Jp Calderone exarkun at intarweb.us
Wed Feb 19 21:51:40 CET 2003


On Wed, Feb 19, 2003 at 12:05:41PM -0800, Michele Simionato wrote:
> [snip]
> 
> The problem is that writing "full_name = property(get_full_name)" in
> the class scope, as you do, put "full_name" in the class dictionary, 
> not in the instance dictionary (this is the standard behaviour).
> You should write in the __init__ method something like
> 
> "self.full_name=property(self.get_full_name)"
> 
> This will give you as output
> 
> <Person first=mark last=mceahern full=<property object at 0x8108a7c>
> 
> and from there you should be able yourself to figure out where to go ;)
> 

  Except that, unfortunately, properties won't work as instance attributes,
only as class attributes.

  Jp

-- 
There are 10 kinds of people: those who understand binary and those who do
not.
-- 
 up 11 days, 0:28, 5 users, load average: 0.19, 0.07, 0.06
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20030219/8489c871/attachment.pgp>


More information about the Python-list mailing list