Subclassing the min() build-in function?

Peter Lorenzen oracle_vs_ms at yahoo.dk
Wed Nov 6 12:11:04 EST 2002


Hi,

I am using Jython to calculate a string like this:  "2+3+min(1,2,3)"
from my Java pro-gram. This works beautifully. But my problem is that
if a user wants to calculate min(1) Python considers this an error. I
want it to return 1. If I could figure out how to subclass the min
function, so when it was called with one parameter I just returned
this parame-ter, and otherwise returned the super min function. It
looks like this should be possible, but I am new to Python, so I don't
understand the subclass examples I have found.

Hope somebody can help me.
Regards,
Peter Lorenzen



More information about the Python-list mailing list