Problem with script and typing
Moshe Zadka
moshez at math.huji.ac.il
Fri Jun 9 14:40:20 EDT 2000
On Fri, 9 Jun 2000, Thaddeus L. Olczyk wrote:
> >> null=Project("")
> >> projects.remove(null)
> > ^^^^^ projects are compared by identity, unless you supply an
> > __cmp__ method
> >
> I'm not sure exactly what you are trying to say here. The Project
> constructor is supposed to insert self into the list. So if you are
> trying to say the null may not be removed , I don't think so because
> they are the same instance.
I see. The Project constructor you posted did *not* put anything into any
global list.
> def __cmp__method(self,rhs):
> return self.name == rhs.name
> in the Projects clas, you are right. I didn't know.
No, I meant it would be easier to put:
def __cmp__(self, other):
return cmp(self.name, other.name)
In the project constructor. But I didn't understand what you were trying
to do there, so never mind.
> Actually it is the return x which whould have read return project.
I didn't see any "return x". Posting short, but *complete*, code will get
you higher quality answers.
--
Moshe Zadka <moshez at math.huji.ac.il>
http://www.oreilly.com/news/prescod_0300.html
http://www.linux.org.il -- we put the penguin in .com
More information about the Python-list
mailing list