On Tue, Jun 19, 2012 at 1:44 AM, jmfauth <wxjmfa...@gmail.com> wrote: > I do not see why the semantic may vary differently > in code source or in an interactive interpreter, > esp. if Python allow it!
When you're asking for input, you usually aren't looking for code. It doesn't matter about string literal formats, because you don't need to delimit it. In code, you need to make it clear to the interpreter where your string finishes, and that's traditionally done with quote characters: name = "Chris Angelico" # this isn't part of the string, because the two quotes mark off the ends of it And you can include characters in your literals that you don't want in your source code: bad_chars = "\x00\x1A\x0A" # three characters NUL, SUB, LF Everything about raw strings, Unicode literals, triple-quoted strings, etc, etc, etc, is just variants on these two basic concepts. The interpreter needs to know what you mean. With input, though, the end of the string is defined in some other way (such as by the user pushing Enter). The interpreter knows without any extra hints where it's to stop parsing. Also, there's no need to protect certain characters from getting into your code. It's a much easier job for the interpreter, which translates to being much simpler for the user: just type what you want and hit Enter. Quote characters have no meaning. Chris Angelico -- http://mail.python.org/mailman/listinfo/python-list