python list implementation

Python list implementation

深入 Python 列表的内部实现

This post describes the CPython implementation of the list object. CPython is the most used Python implementation.

Lists in Python are powerful and it is interesting to see how they are implemented internally.

Following is a simple Python script appending some integers to a ...

more ...

nginx + gunicorn + supervisior + flask 部署 python web

简介

  • 最近离职休假,在家研究 python 的 web 框架
  • 本来是要来 tornado 的,但是因为 Falsk 文档更为齐全,并且更易上手,所以先来了flask
  • 做了一个小 web 之后就想发布,看了一下官方文档说了 Heroku 云服务和其他的 VPS,于是上Heroku 上面去折腾了一番
  • 除了 git 和 Heroku 自己的东西,中间在启动的时候有如下代码:
web: gunicorn gettingstarted.wsgi --log-file -
  • gunicorn 是什么?
  • 继续 google 发现了一套比较通用的部署 python web app 的解决方案
  • nginx + gunicorn + supervisior + flask 来吧在本地折腾一番吧 ...
more ...

Best Python Resources

翻译了一篇文章,原文链接为 http://www.fullstackpython.com/best-python-resources.html

Full Stack Python

Best Python Resources

Python 社区在分享细节的学习资源和帮助初学者掌握语言方面总是很积极热情的,但是也就是因为太多的资源导致人们很难知道如何找到它们。 本文整理了最好、最通用的 Python 资源,并且简述了其内容。

如果您更喜欢通过视频的方式来学习可以点击最好的python视频。如果有兴趣您也可以阅读一下代码开发环境

写给编程新手的

如果你是学习第一门编程语言,本小节的书是比较适合你的。如何在学习Python之前你已经学习过其他的编程语言,请跳过此小节直接到下一小节——“有经验的开发者”。

  • 想要同一时间了解 Python,Django 和 Flask,可以考虑购买Fletcher,Michael和Jeremy三人提供Real Python课程
  • 短短 5 分钟的视频告诉你为什么去思考自己想要构建的项目,去编程解决自己想要解决的问题是更好的选择。在这些项目和问题上花心思比一头栽进一个朋友推荐的特定语言要好。
  • 全民计算机是一本由哈威穆德学院教授编写的公开图书 ...
more ...

windows 迁移 pelican 到 Mac 机器测试

  • 就是一个测试
  • 在Mac机器上面使用pelican,很多的配置都有更改,如果测试通过了,我会把diff贴在下面的
  • 先看看一下 diff Makefile
diff --git a/Makefile b/Makefile
index e69e9c8..c98df1f 100644
--- a/Makefile
+++ b/Makefile
@@ -107,6 +107,12 @@ cf_upload: publish
        cd $(OUTPUTDIR) && swift -v -A https://auth.api.rackspacecloud.com/v1.0 -U $(CLOUDFILES_USERNAME) -K $(CLOUDFILES_API_KEY) upload -c $(CLOUDFILES_CONTAINER) .

 github: publish
+       git ...
more ...

python re.sub

sub(pattern, repl, string, count=0, flags=0)
    Return the string obtained by replacing the leftmost
    non-overlapping occurrences of the pattern in string by the
    replacement repl.  repl can be either a string or a callable;
    if a string, backslash escapes ...
more ...

python const

  • python 没有const 这样的语法,但是在项目中可能会有这样的需求?
  • 自己动手丰衣足食!!!

const.py

  • 首先创建一个const.py文件,代码如下
# -*- coding: UTF-8 -*-

'''
Last modified time: 2015-06-09 09:49:29
Edit time: 2015-06-09 09:55:07
File name: const.py
Edit by caimaoy
'''

__author__ = 'caimaoy'

class _const(object):
    class ConstError(TypeError): pass
    class ConstCaseError(TypeError): pass

    def __setattr__(self, name, value ...
more ...

python split

str.split

Help on method_descriptor:

split(...)
    S.split([sep [,maxsplit]]) -> list of strings

    Return a list of the words in the string S, using sep as the
    delimiter string.  If maxsplit is given, at most maxsplit
    splits are done. If sep is not specified or is None, any
    whitespace string ...
more ...