[Python-Dev] Re: PEP 292 - Simpler String Substitutions

Clark C. Evans cce at clarkevans.com
Mon Aug 23 18:12:33 CEST 2004


+1 to automatic str() -- this is a common newbie mistake and I can't
think of a case where you wouldn't want this to happen

On Mon, Aug 23, 2004 at 08:54:46AM -0700, Michael Chermside wrote:
| Fran?ois Pinard writes:
| > [quotations from the PEP motivation] let me think that people will often
| > forget to stringify numbers and various other value types,
| 
| I agree. I'd like to raise a small voice in favor of automatically
| calling str() on all arguments before interpolation. I'd rather
| type this:
| 
|     # ... code ...
|     out.write( template("$foo\t$bar\t$baz\n") % locals() )
| 
| than this:
| 
|     # ... code ...
|     out.write( template("$foo\t$bar\t$baz\n") %
|         {'foo': str(foo), 'bar': str(bar), 'baz': str(baz)} )


More information about the Python-Dev mailing list

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant