Ron Adam wrote:
> 
> Greg Ewing wrote:
 >
>> Some types may recognise when they're being passed
>> a format spec that belongs to another type, and try
>> to convert themselves to that type (e.g. applying
>> 'f' to an int or 'd' to a float).
> 
> After thinking about this a bit more, I think specifiers don't have 
> types and don't belong to types.

I agree - I was kind of speaking in shorthand there.
What I really meant was that some types have some knowledge
of format specifiers recognised by other types. E.g.
int doesn't itself know how to format something using
a spec that starts with 'f', but it knows that float
*does* know, so it converts itself to a float and
lets float handle it from there.

If you were to pass an 'f' format to something that
had no clue about it at all, e.g. a datetime, you
would ultimately get an exception. And there's
nothing stopping another type from recognising
'f' and doing something of its own with it that
doesn't involve conversion to float (e.g. decimal).

So the one-to-many mapping you mention is accommodated.

--
Greg
_______________________________________________
Python-3000 mailing list
Python-3000@python.org
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to