[Python-Dev] Will the new type system allow automatic coercion?

Jack Jansen jack@oratrix.nl
Wed, 04 Jul 2001 23:46:05 +0200


Something I've suddenly started to need is automatic coercion implemented
by the source type. I have a type implemented in C, and while
automatic coercion from any other type to my type is easy to implement
(in your O& routine you simply check whether the passed object is of a
type you can coerce) there is no way to do the reverse (at least, not
that I'm aware of, please enlighten me).

And now I have this CFString type (a wrapper around the MacOS
CoreFoundation object. Nice things, by the way, these CoreFoundation
objects, sort-of inherited from NextStep and they share a lot of
design with Python objects, but I digress) that can show itself as a
Unicode string or an 8 bit string or a number of other things. It
would be nice if users could pass these CFString objects in places
where a string or unicode is expected. Simply said, if PyArg_Parse s
format would accept my objects.

Will the new type system allow me to do this?
--
Jack Jansen             | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@oratrix.com | ++++ if you agree copy these lines to your sig ++++
www.oratrix.nl/~jack    | ++++ see http://www.xs4all.nl/~tank/ ++++