python-mode

《Python趣味创意编程》新书上架了

倾然丶 夕夏残阳落幕 提交于 2021-01-17 16:57:14
知乎视频 ​ www.zhihu.com 《Python趣味创意编程》新书上架,目前京东、淘宝、当当上搜书名就可以找到,比如: 【官方旗舰店】Python趣味创意编程 零基础入门自学python编程从入门到精通少儿编程入门教程语言程序设计基础数据分析学习手册 ​ detail.tmall.com 出版社图书页面,可以下载相关的代码、图片音乐素材: https://www. epubit.com/bookDetails? id=UBbf16e3464c71 下载Processing、配置Python Mode有问题的读者可以参考这里: 童晶:第1章 Python与Processing介绍(《Python趣味创意编程》教学视频) 本书内容结构 本书通过创意编程案例逐步引入语法知识,用Python从无到有地开发,提升读者对编程的兴趣和能力。全书共16章和两个附录。 第1章介绍了计算机程序和Python编程语言的基本概念,学习了互动艺术开发工具Processing的下载安装。 第2章学习了整数、变量、算术运算符等语法知识,实现了一个转动眼珠的圆脸(20行代码)。 第3章学习了for循环语句、整除、取余等语法知识,实现了催眠的同心圆(12行代码)。 第4章学习了if选择判断、比较大小运算符、逻辑运算符等语法知识,实现了旋转的圆弧(23行代码)。 第5章学习了类型转换

Using multiple Python shells in Emacs 'python-mode' with Python or IPython

余生颓废 提交于 2020-01-22 15:14:25
问题 Is there a way to force a new instance of python-shell while running Emacs? It would be convenient when working on multiple projects with separate working directories (and different sets of modules). Any attempt to invoke python-shell will only pull up the current instance. 回答1: You need to rename your original python-shell before opening up a new one. Use M - x rename-buffer . 回答2: Renaming the buffer doesn't work for me, but you can use the third parameter of run-python . M - : (run-python

In Emacs24 python mode, how to customize each syntax's color?

99封情书 提交于 2020-01-03 06:26:28
问题 For example, I want "while" to be blue, "for" to be green, how to do that? Beyond colors, can I make syntax bold or italic? Thank you so much in advance. 回答1: The easiest way is to put the cursor into a string of the given colour and type M-x set-face-foreground Enter . Then just confirm the face name and specify the colour. To set the face to bold or italic, use set-face-font in a similar way. You can save the settings into your .emacs file: (set-face-foreground 'font-lock-comment-face "gray

How can I set the Python max allowed line length to 120 in Syntastic for Vim?

房东的猫 提交于 2020-01-01 07:36:26
问题 I'm using python-mode for Vim, I prefer for there to be 120 character lines rather than the stark 80 as defined in the PEP8 standard. In python-mode, this is easy. I just add the following to my ~/.vimrc: " Pylint configuration file let g:pymode_lint_config = '$HOME/.pylint.rc' let g:pymode_options_max_line_length=120 This works great, but then, I also wanted to use the superb Syntastic plugin for checking syntax of various other kinds (Chef recipes for foodcritic, for example.) Unfortunately

improper exiting from indentation in emacs python-mode

ε祈祈猫儿з 提交于 2019-12-22 04:38:21
问题 I am using Emacs python-mode. I invoke it using this in my .emacs (add-to-list 'load-path "~/emacs/python-mode.el-6.0.3/") (autoload 'python-mode "python-mode" "Python Mode." t) (add-to-list 'auto-mode-alist '("\\.py\\'" . python-mode)) (add-to-list 'interpreter-mode-alist '("python" . python-mode)) (require 'python-mode) (add-hook 'python-mode-hook (lambda () (set-variable 'py-indent-offset 4) ;(set-variable 'py-smart-indentation nil) (set-variable 'indent-tabs-mode nil) (define-key py-mode

Emacs python-mode: Keyboard shortcuts for pdb step-by-step debugging

China☆狼群 提交于 2019-12-21 12:29:07
问题 I was wondering if there is a way to associate: n RET (next) p RET (previous) c RET (continue) C-x SPC RET (set/clear breakpoint) with function keys F1 - F12 or other keyboard shortcuts. The idea is to emulate the keyboard shortcuts that other IDEs have for debugging (e.g. Visual Studio, MATLAB, etc.). Is this already supported by python-mode? Are there any Emacs modes that can be used to complement python-mode for debugging purposes? 回答1: You always can define own key-bindings in Emacs.

VIM: Use python3 interpreter in python-mode

女生的网名这么多〃 提交于 2019-12-20 09:44:53
问题 I have recently switched to vim and configured it for Python-programming using this tutorial. Before, I have made sure that vim supports python3 (vim --version shows +python/dyn and +python3/dyn) using this article. But when executing a file from python-mode, still the python2.7 interpreter is chosen. How can I configure vim (or the python-mode) to run files on the python3 interpreter? My OS is Ubuntu 14.04 x64. Thanks in advance! 回答1: Try adding this to your .vimrc file let g:pymode_python =

How to control indentation after an open parenthesis in Emacs

断了今生、忘了曾经 提交于 2019-12-18 11:21:30
问题 When I use emacs python-mode, if the last character of a line is an open parenthesis it indents the next line just one step in from the indentation of the previous line. call_some_function( some_very_long_argument_that_I_want_to_put_on_its_own_line) I like that. Now in ecmascript-mode (which I am using for actionscript 3), it always indents to the level of the previous parenthesis. call_some_function( this_is_not_really_saving_me_any_horizontal_space); How can I make ecmascript-mode indent

How can I access directory-local variables in my major mode hooks?

≯℡__Kan透↙ 提交于 2019-12-17 10:55:38
问题 I have defined a .dir-locals.el file with the following content: ((python-mode . ((cr/virtualenv-name . "saas")))) In my .emacs I have the following function to retrieve this value and provide a virtualenv path: (defun cr/virtualenv () (cond (cr/virtualenv-name (format "%s/%s" virtualenv-base cr/virtualenv-name)) ((getenv "EMACS_VIRTUAL_ENV") (getenv "EMACS_VIRTUAL_ENV")) (t "~/.emacs.d/python"))) Finally, in my python-mode-hook list, I have this hook function: (add-hook 'python-mode-hook 'cr

emacs: abbrev-mode can't work in python-mode

ぐ巨炮叔叔 提交于 2019-12-13 06:15:15
问题 I have defined some abbreviations for python mode by using code like this (define-abbrev-table 'python-mode-abbrev-table '( ("i_settings" "from django.conf import settings") ("i_requestcontext" "from django.template import RequestContext") ("i_model" "from django.db import models") ("i_form" "from django import forms") )) but it can't work correctly. for example, I input "i_settings" then input a space, emacs doesn't expand to "from django.conf import settings". I have tried it with all