By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,551 Members | 1,142 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,551 IT Pros & Developers. It's quick & easy.

pychecker - sets.Set need to be overridden

P: n/a
Hello all,

if I have this code:

import sets

class Foo:
x = sets.Set()

then pychecker says:

test.py:4: Methods (__cmp__, __hash__) in sets.Set need to be overridden in a subclass

I don't get this message. What is it trying to say, and why?

Istvan.
Jul 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
mport sets

class Foo:
def __init__(self):
self.x = sets.Set()

x = Foo()
print x, getattr(x, 'x')

gives for me:
<__main__.Foo instance at 0x00C578A0> Set([])
on 2.4. on WinXP. What environment do you run in?

Jul 18 '05 #2

P: n/a
wi******@hotmail.com wrote:
<__main__.Foo instance at 0x00C578A0> Set([])
on 2.4. on WinXP. What environment do you run in?


I'm running it on cygwin,

but still don't get it, why the warning?

Istvan.
Jul 18 '05 #3

P: n/a
Istvan Albert wrote:
if I have this code:

import sets

class Foo:
x = sets.Set()

then pychecker says:

test.py:4: Methods (__cmp__, __hash__) in sets.Set need to be overridden
in a subclass

I don't get this message. What is it trying to say, and why?


The minimal example is actually

import sets
sets.Set()

The Set class has implementations for __cmp__() and __hash__() that
unconditionally raise an exception. pychecker assumes that these methods
are "abstract", i. e. meant to be overriden by a subclass, and warns that
you are instantiating an abstract base class, while the intention of the
Set class author was to make Sets "uncomparable" and unhashable by
overriding the corresponding superclass methods.

Peter

Jul 18 '05 #4

P: n/a
I don't know pychecker, maybe there's something wrong with it as your
code seems valid to me.

Jul 18 '05 #5

P: n/a
Peter Otten wrote:
The Set class has implementations for __cmp__() and __hash__() that
unconditionally raise an exception. pychecker assumes that these methods
are "abstract", i. e. meant to be overriden by a subclass, and warns that
you are instantiating an abstract base class, while the intention of the


I see. Thanks!

Istvan.
Jul 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.