On Sun, Dec 15, 2013 at 11:25:10AM +1000, Nick Coghlan wrote: > Oh, yes, a %T shortcut for "length limited type name of the supplied > object" would be brilliant. We need this frequently for C level error > messages, and I almost always have to look at an existing example to > remember the exact incantation :) What are the chances that could be made available from pure Python too? Having to extract the name of the type is a very common need for error messages, and I never know whether I ought to write type(obj).__name__ or obj.__class__.__name__. A %T and/or {:T} format code could be the One Obvious Way to include the type name in strings: raise TypeError("Expected int but got '{:T}'".format(obj)) looks nicer to me than either of: raise TypeError("Expected int but got '{}'".format(type(obj).__name__)) raise TypeError("Expected int but got '{}'".format(obj.__class__.__name__)) -- Steven
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4