Movatterモバイル変換


[0]ホーム

URL:


[Python-ideas] Briefer string format

Chris Angelicorosuav at gmail.com
Mon Jul 20 06:59:52 CEST 2015


On Mon, Jul 20, 2015 at 2:42 PM, Mike Miller <python-ideas at mgmiller.net> wrote:> Thanks for thinking about it, Chris.  After several mentions of u'' and b''> I was waiting patiently for '' and r''.  I guess r'' does nothing but what> does '' or "" do at runtime?>>     "\tcommand line --params\n"  -->  " command line --params> ">> It looks like there is some runtime conversion happening there, though I> don't know the implementation details.>No, it's not runtime conversion; it's an alternative syntax. Asidefrom unicode vs bytes, all types of string literals are just differentways of embedding a string in your source code; this is why it'ssometimes important to talk about a "raw string literal" rather thanabbreviating it to "raw string", as if the string itself weredifferent.You can play around with it in the interactive interpreter. Allstrings show the same form in repr, namely the unprefixed form (again,apart from a b"..." prefix on bytes); once the compiler has turnedsource code notation into constants, they're just string objects.ChrisA


More information about the Python-ideasmailing list

[8]ページ先頭

©2009-2026 Movatter.jp