The rule of literal string
clp at rebertia.com
Thu Dec 18 01:06:35 CET 2008
On Wed, Dec 17, 2008 at 3:52 PM, Li Han <lihang9999 at gmail.com> wrote:
> Chris worte:
>> And repr("''") ==> "\"''\""
>> Which when print()-ed is: "''"
>> And eval("''") is the same as entering two apostrophes ('') at the
>> REPL, both of which give an empty string object.
> On my machine:
Well, I was kinda winging it and didn't actually use the interpreter
for some of those. The point is that the output I gave _could_
reasonably be that of the interpreter (if the implementation details
of repr() were slightly different; it would still meet the spec
anyway) and illustrates the eval()-repr() relationship.
Just keep in mind the equivalence rule and what repr() does should
Follow the path of the Iguana...
More information about the Python-list