Venv

https://docs.python.org/3/tutorial/venv.html https://docs.python.org/3/library/venv.html

cd /path/to/your/project
python3 -m venv .venv # will create a folder named `.venv` under `/path/to/your/project`.
which pip # You may see `/usr/bin/pip3`
which python # See what?
. .venv/bin/activate.fish # fish user do this
which pip # You will see `/path/to/your/project/.venv/bin/pip3`
which python # See what?

Code Skills

Json formatting

To have a good format of a json result, we can do this:

import requests
import json
response = requests.request()
print(json.dumps(json.loads(response.text), sort_keys=True, indent=4, separators=(",", ": ")))

IPYTHON

pip install ipython
ipython
python manage.py shell -i ipython # in django project

load_ext autoreload
autoreload 2

IPython shortcuts

Fn-Left or Ctrl-a Move cursor to the beginning of the line Fn-Right or Ctrl-e Move cursor to the end of the line Option-Left Move cursor to previous word Option-Right Move cursor to next word

Ctrl-k Cut text from cursor to end of line Ctrl-u Cut text from beginning of line to cursor Ctrl-y paste

%hist -g the_keywords => Search the history command and filter by the_keywords.

With Ruby

在Mac 悠仙美地系统中,貌似Ruby开发环境和Python开发环境无法共存。 安装一些Python和Ruby都用到的包,比如json,Ruby报native extention的错。

因为 http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fails-on-mavericks-and-xcode-5-1-unknown-argument-mul

所以开发Ruby和Python最好用两台分开的机器。

但是,Python是Mac必备的,因为 http://clang.llvm.org/get_started.html 是要Python跑测试的。 而Clang是和Xcode深度绑定的,所以Xcode也是开发者必备的。 报gcc错误,无法编译,可以通过安装xcode develop commandLineTools后设置: $ sudo xcode-select -switch /Library/Developer/CommandLineTools

移除Python

http://stackoverflow.com/questions/3819449/how-to-uninstall-python-2-7-on-a-mac-os-x-10-6-4