Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #91632
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!1.eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Jussi Piitulainen <jpiitula@ling.helsinki.fi> |
| Newsgroups | comp.lang.python |
| Subject | Re: A simple print cannot run in Python Shell |
| Date | Mon, 01 Jun 2015 10:59:29 +0300 |
| Organization | A noiseless patient Spider |
| Lines | 27 |
| Message-ID | <lf5382bq2ou.fsf@ling.helsinki.fi> (permalink) |
| References | <caa1cc9e-2f9b-423d-9298-a511180d15f7@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx02.eternal-september.org; posting-host="305c68510616a2e7ac08bcd2ff1598bd"; logging-data="25245"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19+wdp+0pEb8dVRIkqf9D8gn+nRQ26czyU=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:jJdY8JPoQ8V955znf847PsL8cuc= sha1:0CAF8NG7UYakX8sz/o7xHSyHiyo= |
| Xref | csiph.com comp.lang.python:91632 |
Show key headers only | View raw
fl writes: > When I run the following command in a Python 2.7.9 Shell on Windows 7, > > print r'C:\\nowhere' > > It has error: > >>>> print r'C:\\nowhere' > SyntaxError: invalid syntax > > What is the problem? Why does it behave different at .py file > and Python Shell? Have you executed the following in that shell? from __future__ import print_function That replaces the Python 2 print command with the Python 3 print function and then you would get that error message. Apologies if you've done that because I used it in one of my examples about reversed(). I didn't mean to confuse - I've just never quite learnt the Python 2 print syntax myself. There is no "from __past__ import print_command", is there? To recover the original functionality in that shell :)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A simple print cannot run in Python Shell fl <rxjwg98@gmail.com> - 2015-06-01 00:50 -0700
Re: A simple print cannot run in Python Shell Jussi Piitulainen <jpiitula@ling.helsinki.fi> - 2015-06-01 10:59 +0300
Re: A simple print cannot run in Python Shell Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-06-01 18:30 +1000
Re: A simple print cannot run in Python Shell Tim Golden <mail@timgolden.me.uk> - 2015-06-01 09:46 +0100
csiph-web