Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #35990
| Date | 2013-01-02 09:22 -0500 |
|---|---|
| From | Dave Angel <d@davea.name> |
| Subject | Re: why the output is different when i am implementig multiline string |
| References | <e7c60393-8d39-40f8-9e7a-800b39169721@googlegroups.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1569.1357136556.29569.python-list@python.org> (permalink) |
On 01/02/2013 09:00 AM, stringsatif1@gmail.com wrote: >>>> '''hello > world''' > 'hello\nworld' >>>> fred=''' hello > world''' >>>> print(fred) > hello > world What you're seeing has nothing to do with the triple quotes, and everything to do with how you're using the debugger. In one case, you just mention a value, and the debugger magically calls repr() on the expression. So it adds quotes around it, and turns embedded funny stuff into escape sequences, because that's what repr() does on a string. In the second case, you call Python's print function (assuming python 3, which you didn't specify). it does not call repr(), but just sends the characters direct to the console. if you want to see the escape characters in the second case, you should have either said: >>>fred or >>>print(repr(fred)) -- DaveA
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
why the output is different when i am implementig multiline string stringsatif1@gmail.com - 2013-01-02 06:00 -0800 Re: why the output is different when i am implementig multiline string Chris Angelico <rosuav@gmail.com> - 2013-01-03 01:21 +1100 Re: why the output is different when i am implementig multiline string Dave Angel <d@davea.name> - 2013-01-02 09:22 -0500
csiph-web