Re: The rule of literal string

2008-12-17 Thread Steven D'Aprano
On Thu, 18 Dec 2008 09:34:12 +1000, James Mills wrote: > On Thu, Dec 18, 2008 at 9:25 AM, Chris Rebert wrote: >> As I stated previously, the key rule is: >> >> eval(repr(something)) == something > > This rule is only true for basic data types; Oops, missed this, and the follow ups. Note to se

Re: The rule of literal string

2008-12-17 Thread Steven D'Aprano
On Wed, 17 Dec 2008 15:25:41 -0800, Chris Rebert wrote: > 2008/12/17 Li Han : >> On 12月18日, 上午7时12分, Scott David Daniels wrote: >> Scott wrote: >>> Try: print repr(repr("'")) >>> that might enlighten you. >> >> I found that print( repr( repr( arbitarystring ) ) ) == repr ( >> arbitarystring ) >

Re: The rule of literal string

2008-12-17 Thread Chris Rebert
On Wed, Dec 17, 2008 at 3:52 PM, Li Han wrote: > Chris worte: > [snip] >> 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: repr("''") > '"\

Re: The rule of literal string

2008-12-17 Thread Li Han
Chris worte: [snip] > 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: >>> repr("''") '"\'\'"' Han -- http://mail.python.org/mailman/listinfo/python-li

Re: The rule of literal string

2008-12-17 Thread Chris Rebert
On Wed, Dec 17, 2008 at 3:34 PM, James Mills wrote: > On Thu, Dec 18, 2008 at 9:25 AM, Chris Rebert wrote: >> As I stated previously, the key rule is: >> >> eval(repr(something)) == something > > This rule is only true for basic data types; > > For example: > eval(repr(1)) == 1 > True e

Re: The rule of literal string

2008-12-17 Thread James Mills
On Thu, Dec 18, 2008 at 9:25 AM, Chris Rebert wrote: > As I stated previously, the key rule is: > > eval(repr(something)) == something This rule is only true for basic data types; For example: >>> eval(repr(1)) == 1 True >>> eval(repr([1, 2, 3])) == [1, 2, 3] True >>> eval(repr({"a": 1, "b": 2,

Re: The rule of literal string

2008-12-17 Thread Chris Rebert
2008/12/17 Li Han : > On 12月18日, 上午7时12分, Scott David Daniels wrote: > Scott wrote: >> Try: print repr(repr("'")) >> that might enlighten you. > > I found that print( repr( repr( arbitarystring ) ) ) == repr > ( arbitarystring ) As I stated previously, the key rule is: eval(repr(something)) ==

Re: The rule of literal string

2008-12-17 Thread Li Han
On 12月18日, 上午7时12分, Scott David Daniels wrote: Scott wrote: > Try: print repr(repr("'")) > that might enlighten you. I found that print( repr( repr( arbitarystring ) ) ) == repr ( arbitarystring ) -- http://mail.python.org/mailman/listinfo/python-list

Re: The rule of literal string

2008-12-17 Thread Scott David Daniels
Li Han wrote: But what repr() do remain a black hole! Han Try: print repr(repr("'")) that might enlighten you. -- http://mail.python.org/mailman/listinfo/python-list

Re: The rule of literal string

2008-12-17 Thread Li Han
But what repr() do remain a black hole! Han -- http://mail.python.org/mailman/listinfo/python-list

Re: The rule of literal string

2008-12-17 Thread Li Han
Thank you, Chris! You have made me learn more about Python. -- http://mail.python.org/mailman/listinfo/python-list

Re: The rule of literal string

2008-12-16 Thread Chris Rebert
On Tue, Dec 16, 2008 at 9:32 PM, Li Han wrote: > Hi! I just began to read the tutorial of python3.0 and I just can't > figure out the rule of literal string. There is a example in the > tuotrial: >>>> '"Isn\'t," she said.' > '"Isn\&#

The rule of literal string

2008-12-16 Thread Li Han
Hi! I just began to read the tutorial of python3.0 and I just can't figure out the rule of literal string. There is a example in the tuotrial: >>> '"Isn\'t," she said.' '"Isn\'t," she said.' It is not what I want, I just want '