Dumb*ss newbie Q

Jp Calderone exarkun at divmod.com
Sun Mar 27 20:15:34 EST 2005


On Sun, 27 Mar 2005 17:06:05 -0800, Captain Dondo <yan at nsoesipnaemr.com> wrote:
> [snip]
> 
>     def url (self):
>         self.url = ...
> 
>     def thumb (self):
>         self.thumb = ...
> 
> [snip]
> 
> The problem is that m.html in the test section fails with 
> 
> TypeError: cannot concatenate 'str' and 'instancemethod' objects
> 
> [snip]

    Notice that you have a method named "url" as well as an attribute named "url".  You have the same problem for "thumb".  These methods and attributes are in collision with each other.  When you try to look up the attribute, you might get the method.  When you try to look up the method, you might get the attribute.  It is deterministic, but depends on the order in which you do things, and highly confusing no matter what.  Avoid naming attributes and methods the same thing.

  Jp



More information about the Python-list mailing list