[issue23479] str.format() breaks object duck typing

2015-02-18 Thread Eric V. Smith
Changes by Eric V. Smith : -- resolution: -> not a bug status: open -> closed ___ Python tracker ___ ___ Python-bugs-list mailing lis

[issue23479] str.format() breaks object duck typing

2015-02-18 Thread Mahmoud Hashemi
Mahmoud Hashemi added the comment: Well, thank you for the prompt and helpful replies everyone. Can't say I didn't wish the default behavior were more intuitive, but at least I think I have an idea how to work this. Thanks again! -- resolution: not a bug -> status: closed -> open ___

[issue23479] str.format() breaks object duck typing

2015-02-18 Thread Eric V. Smith
Eric V. Smith added the comment: As David says, the change from: ValueError: Unknown format code 'f' for object of type 'str' to: TypeError: non-empty format string passed to object.__format__ is quite intentional. Let me address the differences between %-formatting and __format__-based formatt

[issue23479] str.format() breaks object duck typing

2015-02-18 Thread R. David Murray
R. David Murray added the comment: This is an intentional change. See issue 7994 for the motivation. This was mentioned in the whatsnew documentation for 3.4. -- nosy: +r.david.murray resolution: -> not a bug stage: -> resolved status: open -> closed ___

[issue23479] str.format() breaks object duck typing

2015-02-18 Thread Martin Panter
Martin Panter added the comment: My guess is you could make it work by adding a __format__ method to your custom class. def __format__(self, format_spec): return format(float(self), format_spec) -- nosy: +vadmium ___ Python tracker

[issue23479] str.format() breaks object duck typing

2015-02-18 Thread Mahmoud Hashemi
Changes by Mahmoud Hashemi : -- nosy: +Mark.Williams ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://ma

[issue23479] str.format() breaks object duck typing

2015-02-18 Thread Mahmoud Hashemi
New submission from Mahmoud Hashemi: While porting some old code, I found some interesting misbehavior in the new-style string formatting. When formatting objects which support int and float conversion, old-style percent formatting works great, but new-style formatting explodes hard. Here's a