Python + UnitTest + cProfile + Mock
Problem? Another day in work and I find out that in one of our projects unit tests suite executes in about 13 seconds . Wow! It was like 200ms before, so what happened? Btw - this particular project...
View ArticlePythonic code review
Most of us programmers go through technical interviews every once in a while. At other times, many of us sit on the opposite side of the table running these interviews. Stakes are high, emotions run...
View Article记一次Django数据迁移Bug
Django的Model是按照每次的migrations管理(即app下的migrations包)的。每次更新Model之后,都需要先运行 python manage.py makemigrations 进行生成migration,这些migrations中记录了数据库的变更,然后用 python manage.py migrate 应用这些更改。...
View ArticleBDD for C++ Projects With Python and Behave
For my current project Fix, I use python and Behave for Behavior Driven Design (BDD). Today I’ll describe my process and the tools I use. In my initial post about Fix, I already wrote a paragraph or...
View ArticleDjango is Boring, or Why Tech Startups (Should) Use Django
I recently attended Django Under The Hood in Amsterdam, an annual gathering of Django core team members and developers from around the world. A common theme discussed at the conference this year is...
View ArticleRunning Python Background Jobs with Heroku
Recently, I’ve been working on a project that scrapes Reddit looking for links to products on Amazon. Basically the idea being that there’s valuable info in what people are linking to and talking...
View Articlepython学习笔记-类和实例
面向对象最重要的概念应该就是类(class)和实例(instance)了。记得以前学习java的时候,有一个比较简单的例子来解释类和实例。 在汽车制造过程中,我们需要先设计图纸,让后再根据图纸来制造实际的汽车。类就相当于图纸,而实例则是实际的汽车。一张图纸可以造出很多汽车,刚造出的汽车是一样的,但是后续可以进行个性化的改装。...
View Article用Python做地图投影 - 多面孔的世界
(如需转载,请在显著位置注明个人微信公众号 stdrei ) 为什么要做地图投影 简而言之,地球表面是一个三维的曲面,在曲面上进行测量是非常困难的。不信你拿个地球仪量一下两点的距离或者计算个夹角试试。将三维的曲面投影到二维平面,这样我们学的平面几何才有用武之地。 什么是投影 如果要了解地图投影,首先需要知道 地理坐标系 和 投影坐标系...
View Article使用 Python 进行并发编程:我为什么不喜欢 Gevent
在python的发展历史中,有过一些失败的修复CPython的缺陷和提高性能的尝试,比如消除GIL、Stackless(一个微线程扩展,避免传统线程所带来的性能与复杂度问题)、psyco (被PyPy代替)、 Unladen Swallow 。当然也有少数成功的,比如PyPy。 协程 在开始表达我的观点之前,我们先来了解下Coroutine。 Coroutine 也就是 corporate...
View ArticleCodementor: Laser Cutting with Python
Wouldn't it be cool that apart from making apps, you can also produce physical things with your coding skills? This basic tutorial will show you how you can use the python Turtle library to create...
View Article您所应了解的Python四大主流网络编程框架
本文内容摘录自《python高效开发实战――Django、Tornado、Flask、Twisted》一书。该书分为三部分:第1部分是基础篇,带领初学者实践Python开发环境和掌握基本语法,同时对网络协议、Web客户端技术、数据库建模编程等网络编程基础深入浅出地进行学习;第2部分是框架篇,学习当前最流行的Python...
View Articlepython调用父类方法
起步 python中有两种方法可以调用父类的方法: super(Child, self).method(args) 和 Parent.method(self, args) 。我用其中的一种报了如下错误: 找不到 classobj 。当我把调用改为 super(B, self).f(name) 就能正确运行,且结果正确。 分析错误 因为基类没有继承 object ,...
View Article理解 Python 迭代对象、迭代器、生成器
本文源自 RQ 作者的一篇博文,原文是 Iterables vs. Iterators vs. Generators ,俺写的这篇文章是按照自己的理解做的参考翻译。 在了解python的数据结构时,容器(container)、可迭代对象(iterable)、迭代器(iterator)、生成器(generator)、列表/集合/字典推导式(list,set,dict...
View Articlepython fnmatch 学习小结
fnmatch主要是用来判断一个文件名是否匹配”Unix shell-style wildcards”这种模式,就是平常用的那种 ls *.log 这样,看是否匹配。 用法很简单,常用也就这两个函数 fnmatch / filter : In [36]: import fnmatch In [37]: import os #判断文件名是否匹配某个模式 In [38]: for file in...
View ArticlePython 发射导弹的正确方式
Toby , python中文社区专栏作者,目前供职于国内最大的医药大数据平台,任数据分析组长。关注自然语言处理,英文密码学,医药统计学。 博客 : http://www.cnblogs.com/webRobot ― ― ――此文以纪念南京大屠杀79周年 今天Toby教你如何用python的basemap包绘制轰炸东京的地图。...
View ArticleGraphQL+Django提供基本API
GraphQL 是Facebook去年开源的一套数据查询语言,对于大型系统,GraphQL提供一种灵活的访问通用数据的方式。当时正好有一个项目,需要前端调用后台的数据(Postgresql)实现图表展示,我就从Postgresql里把数据导出成JSON文件,前端直接用GraphQL获取自己需要的数据,后台也省掉了制作API、写SQL的工作,运行至今基本稳定。...
View Article一点微小的工作
正在上计量经济学的时候,还在想计量中虚拟变量的引入和机器学习中多分类学习的“一对多”有什么关系,就看到收件箱里有 A Byte of python 的作者 Swaroop C H 发来 6 封邮件(其实是 GitHub 的提醒邮件)。 第一次 Merged 就是我之前在回答和博客中多次提到的这本书: 为什么看不懂廖雪峰python? 、 A Byte of Python...
View ArticleBuild a blog with Django
The best way to learn a new web framework is by using it to build something. If you can't think of any cool ideas then the tried and true approach of implementing your own blog is a fantastic option...
View ArticleQingStor 对象存储新增 6 种语言 SDK
为了让更多的用户能够快速便捷的使用 QingStor对象存储服务,我们在原有pythonSDK 的基础上,新增Go、Ruby、Swift、Java、javascript 及 php, 6 种语言的 SDK。 目前 QingStor 对象存储服务的 SDK 已覆盖主流编程语言和开发平台,极大降低了用户使用 QingStor 对象存储服务的成本。 更重要的是,我们开源了 QingStor...
View ArticleDatabase Load heatmap with AWR and Python
Recently, one of my customer asked me to design him a tool to quickly see the database load. He already did that for another Rdbms with a heatmap. To do that, I used two distinct part in my work: Data...
View Article