On Sun, Mar 1, 2009 at 1:50 PM, Sean Novick <daddysea...@yahoo.com> wrote:

> Here is the bit of code my error was refering to:
> class phonedb:
>
> some definitons...
>
>     def lookup(self, string):
>         list = []
>         for key in self.shelve.keys():
>             e = self.shelve[key]
>         if cmp(e, string) == 0:
>             list.append(e)
>             return(list)
>
> where would it tell me to return an int?
>
>
cmp(e, string) is actually just a shortcut for e.__cmp__(string). Again, you
should almost never directly call cmp. First of all, newer code should
implement the __eq__ method for this, not cmp. Also, you should just use "if
e == string" instead of cmp or eq. This isn't java- Python has operator
overloading (though it isn't quite as flexible as C++).
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to