bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#39070: python interpreter within Emacs fails on simple test (syntax


From: Pierre ALBARÈDE
Subject: bug#39070: python interpreter within Emacs fails on simple test (syntax error)
Date: Fri, 10 Jan 2020 11:29:58 +0000
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:60.0) Gecko/20100101 Thunderbird/60.9.1

This small program

mac2011% cat bug.py
print(__name__ == "__main__")
#if True:
if __name__ == "__main__":
    print("main")
else:
    print("not main")

works well in Terminal :

mac2011% python bug.py
True
main

mac2011% python --version
Python 3.6.9 :: Anaconda, Inc.

but it does not work in Emacs python mode :

mac2011% Emacs -Q bug.py

(version)
"GNU Emacs 28.0.50 (build 1, x86_64-apple-darwin15.6.0, NS appkit-1404.47 Version 10.11.6 (Build 15G22010))
 of 2020-01-09"

Files opens in (Python ElDoc) mode

Python menu

Start interpreter (C-c C-p)

Eval buffer (C-c C-c)

Python 3.6.9 |Anaconda, Inc.| (default,     Jul 30 2019, 13:42:17)
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or     "license" for more information.
>>> python.el: native completion setup loaded
>>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/alba/Documents/projets/plot time series/bug.py", line 5
    else:
       ^
SyntaxError: invalid syntax
>>>

Replacing 'if __name__ == "__main__":' by 'if True:', there is no more error.

Replacing "__main__" by "__main_", there is no more error.

Same with Python 3.7.6.

'print("main") if __name__ == '__main__' else  print("not main")' works.

Best regards.

--
Pierre ALBARÈDE



Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]