Tôi đã cài đặt flycheck cho Emacs Python trên Ubuntu 15.04.Emacs: Làm thế nào để tôi đặt flycheck cho Python 3?
Tuy nhiên, khi sử dụng công cụ báo cáo dương tính giả như print(item, end=' ')
là sai cú pháp do end
.
Tôi biết đây là Python 3 cú pháp, và rằng các lỗi cú pháp là do flycheck được thiết lập cho Python 2.
Làm thế nào để tôi thiết flycheck lên cho Python 3?
Trong tài liệu trên Github, nó không đề cập đến việc nó hỗ trợ Python 2 hay 3 (chỉ Python).
Ngoài ra, nếu có thể, hãy cho tôi biết lý do tại sao công cụ elpa không đưa ra đề xuất cho ví dụ: các loại Python cơ bản.
tập tin init.el của tôi là ở đây:
;; init.el --- Emacs configuration
;; INSTALL PACKAGES
;; -------------------------------------
(require 'package)
;; Primary Emacs repository is MELPA
(add-to-list 'package-archives
'("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(when (not package-archive-contents)
(package-refresh-contents))
(defvar myPackages
'(better-defaults
elpy ;; Emacs Lisp Python Environment
flycheck ;; flycheck Python syntax-checking
material-theme))
(mapC#'(lambda (package)
(unless (package-installed-p package)
(package-install package)))
myPackages)
;; BASIC CUSTOMIZATION
;; -------------------------------------
(setq inhibit-startup-message t) ;; hide startup message
(load-theme 'material t) ;; load material theme
(global-linum-mode t) ;; enable line numbers globally
(global-flycheck-mode) ;; enable flycheck globally
;; PYTHON CONFIGURATION
;; -------------------------------------
(elpy-enable) ;; enable elpy
;; use flycheck, not flymake with elpy
(when (require 'flycheck nil t)
(setq elpy-modules (delq 'elpy-module-flymake elpy-modules))
(add-hook 'elpy-mode-hook 'flycheck-mode))
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(python-shell-interpreter "python3"))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; init.el ends here
Cú pháp Python 2 có hợp lệ cú pháp Python 3 không? – Shuzheng
Đối với hầu hết các phần, có một số khác biệt mặc dù. Ví dụ python3 không có 'execfile' và một vài thứ khác như giảm – Jules