[IronPython] why?

J. Merrill jvm_cop at spamcop.net
Wed Sep 15 15:54:30 CEST 2004


At 04:02 AM 9/15/2004, Curt Hagenlocher wrote (in part)

>It would be nice if ReflectedMethodBase.Call would try to find
>the best match instead of the first available match, but it would
>probably be cleaner to eliminate the automatic cast of string to
>boolean.  Is there anyplace other than a conditional expression
>where this is legal in Python?

Though I'm not a fluent Python programmer, I don't know of any reason not to remove that automatic cast of not just string, but integer and object, to boolean, other than in the context where a true/false value is being sought (in a conditional expression).

Otherwise, FePy could find
   someMethod(boolean)
before it finds
   someMethod(object)
or
   someMethod(integer)
as well as the
   someMethod(string)
case mentioned here.

Perhaps ReflectedMethodBase.Call needs a new, optional, boolean parameter (default false) indicating whether an automatic cast to boolean should happen.

Another important question is whether there is a way to work around this in the current code.  I'd guess that
   WriteLine("%s", "string")
would work, but that sure looks like something you would not want to make into an idiom long-term.

J. Merrill / Analytical Software Corp




More information about the Ironpython-users mailing list