跳过Python的坑点
python小技巧真的很多,而且有些还是导致BUG或模糊定义。这篇文章总结下,避免踩坑。 根据Python数据结构分类如下: 列表相关 一. 列表相关 1.1 超出索引不一定就报错 这有点不可思议,超出列表索引一般都会报IndexError异常,如下: >>> list = ['a', 'b', 'c', 'd', 'e'] >>> list[100]...
View ArticleIntroducing GOV.UK Frontend Alpha
An early prototype of the GOV.UK Frontend site We’re working on a new project at GDS to create a simpler, better way of building user interfaces for government services. Earlier this year we ran a...
View ArticlePython-闭包
1.闭包的概念 闭包是一个包含有环境变量取值的函数对象,是一种组织代码的结构,闭包的功能在于,它提高了代码的可重用性。 2.闭包的使用 关于闭包是什么样的形式,又是如何使用的,我们来看几段代码; code1: def line_func(): def line(x): return 5*x + 1 return line #返回函数对象 line_hl = line_func()...
View Article[Python]-14-多进程
引言 在硬件条件允许的情况下,使用多进程编程可以提高程序的执行效率,这篇文章将介绍如何让python程序实现多进程。 文章目录 0×1.Unix/linux系统与Fork() 0×2.使用multiprocessing模块实现多进程 a.使用Process类创建进程对象 c.使用Queue实现进程间通信 0×1.Unix/Linux系统与Fork()...
View ArticleInside the Python Virtual Machine
About the Book Inside the python Virtual Machine provides a guided tour under the covers of the Python interpreter for the curious pythonista. It attempts to show the user what happens from the moment...
View ArticlePyCharm 2016.3 EAP 3 (build 163.6110.26)
Weekly previews of PyCharm 2016.3 continue with the third PyCharm 2016.3 EAP build number 163.6110.26. Download and try it today. Let’s take a look at what’s new in this build: Code completion for...
View Articleproblems with django_extension's graph_models?
I recently ran into an issue when trying to generate an image of my project's models using django_extension 's graph_models command. Unfortunately, googling for the error didn't turn up any solutions,...
View ArticleThoughts on PyArkansas
I make a decent effort to keep up with what's happening in the python comunity, but― gosh darnit ―it's hard! I think that's why conferences exist. They give you a day or two to focus solely on meeting...
View ArticleA Guide to Using Git in PyCharm Part 2
This post is part 2 of a multi-part series intended to describe how to use PyCharm’s integrated Git (version control) features. In my previous PyCharm post (Part 1) , I described how to get started...
View ArticleDjango Manager Testing Woes
I've recently run into some strange behavior while testing some custom Django managers. While, I can't list all of the exact code (it's not open source), I'll try to list some simple examples that...
View ArticlePython内置函数(1)――abs
英文文档: abs( x ) Return the absolute value of a number. The argument may be an integer or a floating point number. If the argument is a complex number, its magnitude is returned 说明: 1....
View Article与Python的初次见面
一、python的介绍 python的创始人为吉多.范罗苏姆。1989年的圣诞期间,吉多.范罗苏姆为了在阿姆斯特丹打发时间,决心开发一个新的脚本解释程序,作为ABC语言的一种继承。 二、Python是一门什么样的语言? 编程语言主要是从以下几个角度进行分类,编译型和解释型、静态语言和动态语言、强类型定义语言和弱类型定义语言。 编译和解释的区别是什么?...
View ArticleDyMerge Bruteforce Dictionary Merging Tool
DyMerge is a simple, yet powerful bruteforce dictionary merging tool written purely in python which takes given wordlists and merges them into one dynamic dictionary that can then be used as ammunition...
View ArticlePython 爬虫学习笔记之正则表达式
正则表达式的使用想要学习 python 爬虫 , 首先需要了解一下正则表达式的使用,下面我们就来看看如何使用。. 的使用这个时候的点就相当于一个占位符,可以匹配任意一个字符,什么意思呢?看个例子就知道 import re content = "helloworld" b = re.findall('w.',content) print b`注意了,我们首先导入了...
View ArticlePython Sweetness: Debugging C extension memory safety with valgrind on CPython
Here is a quick summary of the steps required to prepare a build of python 2.7 for use with valgrind memcheck tool. Valgrind is an indispensable tool for discovering memory safety issues, and for...
View ArticleMy First Week at ActiveState
I’ve had an interesting career so far. I moved out west from Ontario to “find myself” as they say. I’d never even been to Vancouver, but moving here seemed like a good idea. That was 12 years ago. Once...
View ArticlePyData Carolinas 2016 Recap
We had a great time at the inaugural PyData Carolinas hosted nearby at IBM in the Research Triangle Park. People from Caktus presented a number of talks and the videos are now up online: Erin Mullaney...
View ArticleDjango Tips #18 Difference Between ugettext And ugettext_lazy
The Django translation API provides several utility functions to help you translate your application. They are all available in the django.utils.translation module. For the most cases you will be...
View ArticleInterfacing with NewPort Motion Controllers on a Mac
This post describes how to interface with a NewPort Motion Controller over USB using a Mac. This process uses python, with the pyUSB module and the libusb-compat backend. The script launches a console...
View Article