ningning.today
规范 | Pegasus' Blog
http://ningning.today/tags/规范
ningning.today
使用docker-compose运行错误收集工具Sentry | Pegasus' Blog
http://ningning.today/2016/10/18/python/docker-sentry
周二, 10月 18 2016, 10:49:09 晚上. Use exceptions for exceptional problems. Exceptions can suffer from all the readability and maintainability problems of classic spaghetti code. Reserve exceptions for exceptional things. Sentry’s real-time error tracking gives you insight into production deployments and information to reproduce and fix crashes. 在ubuntu server上搭建个一个尝试了一下 也可以直接用官方提供的服务 ,感觉还是非常强大的,界面也比较漂亮。 Docker sudo apt- get. Apt-transport-https ca-certificates sudo apt- key. Sudo service docker start.
ningning.today
Getting Started with Pyparsing | Pegasus' Blog
http://ningning.today/2017/01/06/python/getting-started-with-pyparsing
周五, 1月 6 2017, 8:09:42 晚上. Getting Started with Pyparsing. The grammar specification should be a natural-looking part of the Python program, easy-to-read, and familiar in style and format to Python programmers. - Zen of Pyparsing. Combine( ipField ".". IpField ) phoneNum =. C,C ,Java,Pypthon, HTML 注释处理. Identifier = Word(alphas, alphanums ). Number = Word(nums .). AssignmentExpr = identifier = (identifier number). 我们只使用 Backus-Naur Form (BNF). 表示 is defined as. 表示 1 or more. 表示 0 or more. Good', 'morning...
ningning.today
data structures and algorithms using python | Pegasus' Blog
http://ningning.today/2016/12/10/python/data-structures-and-algorithms-using-python
周六, 12月 10 2016, 9:52:38 晚上. Data structures and algorithms using python. I think a lot of new programmers like to use advanced data structures and advanced language features as a way of demonstrating their ability. I call it the lion-tamer syndrome. Such demonstrations are impressive, but unless they actually translate into real wins for the project, avoid them. - Glyn Williams’. How to select datastructures for ADT. Does the data structure provide the data access and manipulation functionality to fully.
ningning.today
unittest | Pegasus' Blog
http://ningning.today/tags/unittest
ningning.today
python单元测试 | Pegasus' Blog
http://ningning.today/2016/08/27/python/python单元测试
周六, 8月 27 2016, 9:05:42 上午. Test your software, or your users will. Test ruthlessly. Don’t make your users find bugs for you. 单元测试 又称为模块测试, Unit Testing 是针对程序模块 软件设计的最小单位 来进行正确性检验的测试工作。 在过程化编程中,一个单元就是单个程序、函数、过程等 对于面向对象编程,最小单元就是方法,包括基类 超类 、抽象类、或者派生类 子类 中的方法。 但是写起来稍微繁琐,比如都要写一个TestCase类,还得用 assertEqual, assertNotEqual等断言方法。 Return a b Args: a (int): int b (int): int Returns: a b Raises: AssertionError: if a or b is not integer " ". All([isinstance(a, int), isinstance(b, int)]) return. Run a single method in.
ningning.today
ubuntu常用工具和python虚拟环境安装脚本 | Pegasus' Blog
http://ningning.today/2016/05/12/Linux/ubuntu常用工具和python虚拟环境安装脚本
周四, 5月 12 2016, 9:36:43 晚上. Make it easy to reuse. If it’s easy to reuse, people will. Create an environment that supports reuse. 地址在这个 https:/ github.com/PegasusWang/linux config. 包含了tmux,vim,docker,zsh等开发常用的工具,vim为python做了配置,包含了各种常用功能。 Usr/bin/env bash #for zh-cn utf8 ubuntu14.04 sudo apt-get update. Pack-zh sudo locale-gen zh CN.UTF- 8. Echo 'LC ALL="zh CN.UTF-8"'. Sudo tee -a /etc/environment sudo dpkg-reconfigure locales # for. Ubuntu common tools sudo apt- get. Y silversearcher-ag sudo apt- get.
ningning.today
python项目免坑指南 | Pegasus' Blog
http://ningning.today/2016/08/20/python/fuck-python
周六, 8月 20 2016, 11:24:14 上午. 上来就from shit import *. PEP 8 Style Guide for Python Code. 因为python没有类型声明,可以适当加上后缀比如url list, info dict等作为区分。 因为不同的人处理日期时候,特别喜欢用date来命名,但是第一眼看到这个date时候你很难知道它是datetime.date还是个类似’2016-10-01’的字符串, 多次都是最后运行到程序抛出异常才知道是什么类型, 你又不能到处都加上个isinstance判断(我严重怀疑所谓的鸭子类型,嘎嘎嘎)。 以至于我养成了一种习惯,比如非常喜欢这样命名,date str list, date str dict, date obj tuple, date str set等这种风格,虽然丑了点又冗余了点,但是我能容易 看出其类型,提升了可维护性,也更易于阅读代码。 有时候我就想python这种动态语言如果能用 匈牙利命名法 是否好维护些呢 有时候感觉这种动态语言只有通过良好的编码规范和文档才能具有可维护性,否则项目大了真是灾难。 功能规格 使用...
ningning.today
python, algorithms | Pegasus' Blog
http://ningning.today/tags/python-algorithms
Data structures and algorithms using python.
ningning.today
编写易维护的python项目 | Pegasus' Blog
http://ningning.today/2016/12/30/python/write-maintainable-python-project
周五, 12月 30 2016, 8:47:31 晚上. Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live.- John Woods. Self, customer,topranking). Testranking = getRanking(customer) return. Testranking topranking / java public boolean isRankingBetter(Customer customer, int topranking) { int testranking = getRanking(customer); return. Testranking topranking; }. 防范离职风险 任何时候需求至少两个人一起对 对需求 ,代码完成后至少经过一个人review,公司经常为了压榨每个程序员的生产力只放手放一个人做,我觉得这是危险的。 I think a lot of new program...