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 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: References: 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 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 :)