On Thursday March 15 2007 6:31 pm, Ofer Nave wrote:

> class SimilaritySansTF(object):
...
>     def idf(self, term, searcher):
>         return self.super.idf(term, searcher)
>
>     def idf(self, terms, searcher):
>         return self.super.idf(terms, searcher)
>
>     def idf(self, docFreq, numDocs):
>         return self.super.idf(docFreq, numDocs)

Python doesn't do signature-overloading.  Your class is going to end up with 
the last definition of idf()

> So, that's definitely a step forward.  However, I'm not very pleased with
> my implementation, and I also have a host of new questions:
>
> 1) Did I implement the subclass wisely?  I only wanted to override tf(),
> but needed to implement many other methods in order to conform.  I also
> didn't want to have to recode the existing logic of the superclass, and I
> didn't know how to properly call the super class methods, so instead I
> instantiatied the superclass in __init__ and delegated to it to calculate
> the answers for me.  This works for state-less classes, but would be
> problematic if I was subclassing a class with state, where my subclass
> would have to share state with the superclass.

Looks pretty much right to me - you might think about passing in self.super as 
an arg to __init__ instead.

> 2) Python doesn't have declared/static types, so how does Java know which
> python idf() method to call?

Beats me. But:
1) you're only going to end up with one idf() method anyway (see above)
2) they'd all have the same signature in python anyway (2 args)
3) you're just passing through to self.super, which is java, so presumably it 
does its evil static typing magic to figure it out.

FWIW, if you're new to python, you picked about the single strangest package 
out there to start with. [0]

--Pete

[0] - outside of some of the Zope insanity, but let's not even go there.

-- 
Peter Fein   ||   773-575-0694   ||   [EMAIL PROTECTED]
http://www.pobox.com/~pfein/   ||   PGP: 0xCCF6AE6B
irc: [EMAIL PROTECTED]   ||   jabber: [EMAIL PROTECTED]
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to