蠎加载 102

原文: Import Python Weekly Newsletter - Issue No 102 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… 如何用 Python 代码来捕获环线地铁上的流氓? pandas Singapore’s MRT Circle Line was hit by a spate of mysterious disruptions in recent months, causing much confusion and distress to thousands of commuters. Like most of my colleagues, I take a train on the Circle Line to my office at one-north every morning. So on November 5, when my team was given the chance to investigate the cause, I volunteered without hesitation. (是也乎: 通过一系列的数据分析,将非法乘车的人群行为可视化, 相关 ipynb 下载:datagovsg-blog/circle-line-analytics 问题是, 新加坡哪! 传说中治安最好的国家之一呢… ) 线程异步魔法以及具体的折腾 python3, asyncio A dive into Python’s asyncio tasks and event loops. The asyncio package allows us to define coroutines. These are code blocks that have the ability of yielding execution to other blocks. They run inside an event loop which iterates through the scheduled tasks and executes them one by one. A task switch occurs when it reaches an await statement or when the current task completes. (是也乎: Py3 也就只能将这拿来说事儿了 ) Python 加载语句中的命名约定.用 BigQuert 对 Github DB Dump 进行探索 github, bigquery Fun article by Florin Badita using BigQuery over entire github hosted Python project’s code base. (是也乎: 细思恐极~ GitHub Data | BigQuery Documentation | Google Cloud Platform GitHub 应该是拿到了 Google 的免费接口支持, 所以能实时的将所有开源项目的仓库数据同步到 BigQuery 上, 这带来了一个直接后果: 我们提交的代码已经变成了互联网意识的一部分! 嗯哼,各种代码代码风格的优劣,现在有了直接的数据支持,可以客观的知道当前世界上程序猿们的真实心理动态了…. 比如: 这个月使用 tab 的多过空格的, 可能是 win13 发布带来的小高潮…etc. Tabs or spaces(圣战分析) 当然有很多技巧的, 主表 [bigquery-public-data:github_repos.contents] 已经 1.5 TB, 不是一般人承担的了查询费用的… ) Tensorflow: 如何用 Python 接口冻结模型并使用 tensorflow, machinelearning We are going to explore two parts of using a ML model in production. How to export a model and have a simple self-sufficient file for it ? How to build a simple python server (using flask) to serve it with TF ?. (是也乎: 又一个用 Flask 落地 TF 服务的案例 ) 四大 Python 可能的未来之纠缠 What does the future hold for Python, aside from new versions of the language ? (是也乎: 嗯哼, Py2 LL&P ) 基于 Microsoft Cognitive 服务和 Python 构建私人 ChatBot chatbots ChatBot is the new buzz word for a while. Microsoft Cognitive Services API allows you to built ones that allow your app to process natural language and learn how to recognize what users want. (是也乎: 就是这种邪恶的免费接口,将程序猿训练为了向企业 AI 投食的机械人! 嗯哼,俺也将给 Cognitive 输入整个儿红楼梦,是否能变成可吟诗的 Bot ? ( ̄▽ ̄) 也支持 Jupyter … M$ 一点儿也不落后. ) 用 Python 可视化 Tweet 向量 data-mining, gensim, tweets I created a semi-practical application that reads from the Twitter stream, parses tweets, and does some machine learning magic to score the tweet’s sentiment and project it into a two-dimensional grid, where tweets with similar content will appear closer to each other. It does all of this more or less in real time using asynchronous messaging. (是也乎: 实时获得 Twitter 的情绪变化 ) 在 Xcode 中跑 Python : 步骤 — Erica Sadun xcode, apple As I’m preparing for a project that will involve Python programming, I need to get up to speed with at least a basic level of Python mastery. However, I’m not a big fan of using the interactive Python REPL. I decided to use Xcode instead, and I’m finding it a much better solution for my needs: (是也乎: Hummm 何苦泥… ) 用 Pickle 进行对象序列化 pickle Introductory article on usage of pickle module. (是也乎: 之前曰过 eevee/camel: Python serialization for adults 更加嗯哼. ) 和 AWS Lambda 一起用 Numba aws, lambda, numba In a recent project, we decided to use Lambda to execute some fairly math-y Python code in response to user click events on a webpage. Originally this back-end Python code had utilized the Numba library to speed up its execution. However, we quickly found that it was not trivial to make Lambda and Numba play nicely together. (是也乎: 事实一再证明 AWS 工程师不是吃素的… Numba 这种基于 LLVM 加速的并发分析工具,都可以简单的移植到 Lambda 中跑起来… ) unittest 中最赞的你应该知道却不一定知道的特性 subTest From time to time I like to read documentation of modules I think I know well. The python documentation is not a pleasant read but sometimes you strike a gem. (是也乎: 所谓灯下黑呗. 终于有子测试了… ) Pytho 中的高级句式匹配 string_maching FuzzyWuzzy is a fantastic Python package which uses a distance matching algorithm to calculate proximity measures between string entries. (是也乎: 使用距离算法来对整句进行相似度分析,当然不支持 中文先… ) 通过异常类定义另你的自制类更加可读 video, screencast, exception_handling In this short screencast I’ll walk you through a simple code example that demonstrates how you can use custom exception classes in your Python code to make it easier to understand, easier to debug, and more maintainable. (是也乎: 其实吧,还是代码写简单点儿最好了. ) 好物 ~ 包/模块/库/片段… ...

2016-12-10 · 4 min · 1890 words · ZoomQuiet

蠎加载 101

原文: Import Python Weekly Newsletter - Issue No 101 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… Quiz Results quiz Thanks everyone for participating in the quiz. Nico Ekkart, Chad Heyne, Artem Bezukladichnii, Andrew Nester and Kyle Monson Congrats. Your copies of Writing Idiomatic Python is on its way. The Answers are on the blog post. ImportPython Subscribers can get a copy of Writing Idiomatic Python for a special price at https://jeffknupp.com/writing-idiomatic-python-ebook-importpython-q2vwt5/ . Thank you Jeff. (是也乎: 上次的问卷结果出来了… ) 俺们如何部署 Python 代码 ? - Nylas deployment Building, packaging, and deploying Python using versioned artifacts in Debian packages. At Nylas, we’ve developed a better way to deploy Python code along with its dependencies, resulting in lightweight packages that can be easily installed, upgraded, or removed. And we’ve done it without transitioning our entire stack to a system like Docker, CoreOS, or fully-baked AMIs. (是也乎: 老梗了,两年前就推荐过,这团队折腾到最后使用了 Debian 专用的 dh-virtualenv 工具, 对于多数团队而言,嗯哼的… ) 如何进行代码格式化令你的 Python 出色? code-quality In Python code reviews I’ve seen over and over that it can be tough for developers to format their Python code in a consistent way: extra whitespace, irregular indentation, and other “sloppiness” then often leads to actual bugs in the program. Luckily automated tools can help with this common problem. Code linters make sure your Python code is always formatted consistently – and their benefits go way beyond that. (是也乎: Flake8+Sublime 的培训课程广告 ) 在 Python 中检查所有条件匹配 - By Trey Hunner core-python Use of any/all with generator expressions for improved readability and code clarity. (是也乎: 运用内建函式 any/all ) 如何成为对冲基金的 Python 程序猿, by the CTO of AHL interview We asked Collier what it takes to code in Python for a major quant fund. – And whether learning how to code as a second career after trading is actually viable. This is what he said. (是也乎: AHL?! 折腾宇宙奥密的 CTO 也转行基金了!? 突然理解了 洪教授… ) 计算科学和工程的 Python 3 book It’s a free book available for download. This text summarises a number of core ideas relevant to Computational Engineering and Scientific Computing using Python. The emphasis is on introducing some basic Python (programming) concepts that are relevant for numerical algorithms. The later chapters touch upon numerical libraries such as numpy and scipy each of which deserves much more space than provided here. We aim to enable the reader to learn independently how to use other functionality of these libraries using the available documentation (online and through the packages itself). (是也乎: 免费图书,用 py3 来演示计算科学领域中各种常见任务的解决, 也介绍了 numpy/scipy 等等关键库. ) Django, fast: part 2 django In this second follow-up post Patryk Zawadzki makes use of wrk benchmarking tool and shows us the performance of gunicorn, uwsgi, PyPy. Besides benchmarking there is good insights into do’s and don’t of each deployment option. (是也乎: 用标准的基准工具来测量 Django 的效能瓶颈 ) Python 内存管理 memory management One of the things you should know, or at least get a good feel about, is the sizes of basic Python objects. Another thing is how Python manages its memory internally. (是也乎: 其实吧,看中国原创的 Python 源代码鉴赏 更加能明白 ) Python 和虚拟环境 virtual environment A tour/tutorial of everything virtualenv. (是也乎: pyenv 早已是每天无法离开的命令了,当然, M$ 中嗯哼的. ) 聊哈对象 “优化”: slots 以及 namedtuples. performance 用 HTRC 特性提取器在 Python 中折腾文本挖掘 data mining We introduce a toolkit for working with the 13.6 million volume Extracted Features Dataset from the HathiTrust Research Center. You will learn how to peer at the words and trends of any book in the collection, while developing broadly useful Python data analysis skills. (是也乎: 基于 1360万卷文献资料的折腾… 可编程历史学 国外各种领域的研究,除了论文发布,关联的重要发布就是一个个的开放数据包. 细思恐极. 当然也使用 ipynb 来组织和展示. ) Awesome Django Admin django-admin Curated list of awesome django resources aptly named Awesome Django Admin . If you have seen Awesome Python, it’s on the same lines. Contribute to it. (是也乎: 细思恐极哪, Awesome 系列是 github 中实事上的好物集锦前缀, 但是, Django Admin 只是一个框架中的一个功能,竟然也能攒出一个 Awesome 来… 这得复杂到什么地步哪… ) 好物 ~ 包/模块/库/片段… ...

2016-12-01 · 3 min · 1455 words · ZoomQuiet

蠎加载 100

原文: Import Python Weekly Newsletter - Issue No 100 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… 蠎加载百期知识竞赛 importpython It’s been 2 years of curating ImportPython and today is the 100th Issue. Wow. What a moment ?. Here is a python quiz competition. Five random() participants who answer all questions correctly win complete bundle of Writing Idiomatic python book by Jeff Knupp. If you take the quiz at the end of it is a link with discount too. This quiz is an our attempt at having fun and saying thanks to all you readers of ImportPython. Do take to twitter with the hashtag #importpython100 happy to hear what you have to say. (是也乎: 追查了一下, 2014-09-25 开始快译 蠎加载 的, 嗯哼,2012-02-17 开始翻译 蠎周刊 的, 当然 蠎周刊 之前有朋友翻译过前20期,俺是从 77 期开始坚持翻译到 200期,引人了新的快译小伙伴,老高, 然后,重心转移到 蠎加载; 风格也从之前正文的翻译,慢慢变成了主要进行 是也乎 的点评; 不变的是很少有人提交 PR,想来也是因为这种周刊,实在只是个定时 技术新闻点收集, 时效性太强,大家参与进来,并不能获得类似伟大的 字幕组 那种可以长期流传,洗脑天下的乐趣. 之于俺和小伙伴,最大的收获的确也就是: 定期翻译,形成周自学节奏 了解 Python 领域的主流变化 积累 Python 技术演化趋势概念 架构选型时帮助扩大思考范围 … 简单的说,定期快译一个技术新闻周刊,是种非常好的强迫自学的形式; 并不特别强烈的建议大家都来加入这种自学,毕竟太散了… 但是,的确是一个有效无意识提高领域技术语感的好形式. ) MLAlgorithms machine learning, algorithms Minimal and clean examples of machine learning algorithms 用 pip 从 github 安装 Python 模块 pip, github pip install --upgrade git+git://github.com/user/user_repository.git and you are done. (是也乎: 现代语言生态的标志行为:加载 github ) 迭代器和生成器 core-python Simple code snippets showing how iterators and generators work in Python. Patrick Kennedy: Flask 应用的单元测试 testing, flask This blog post provides an introduction to unit testing a Flask application. I’ve been on a big unit testing kick at work recently which is spilling over into updating the unit tests for my personal projects. Therefore, I thought it would be a good time to document the basics of unit testing a Flask application. (是也乎: 是的 Flask 的单元测试生态并没有兴起… ) DigitalOcean 中 Tensorflow 的 Python 支持 tensorflow, digitalocean The following steps will install TensorFlow1 on a fresh Digital Ocean virtual machine running Ubuntu. (是也乎: 数字海洋是唯一一个 AWS/GCP 之外最有成功相的 *aaS 厂商了 ) 用 Pandas 构建财务模型 - By Chris Moffitt pandas This specific post will discuss how to do financial modeling in pandas instead of Excel. For this example, I will build a simple amortization table in pandas and show how to model various outcomes. (是也乎: 谁说社科生不玩程序的?! 这在经济领域现在是必须的强项了… ) 定义过滤器和有序字典 django, python3 This week I ran into a minor problem that took a surprising amount of time to resolve. Getting a Django template to produce a dict in sorted order. While there were answers out there, none seemed to match the environment that I am using (python 3, Django 1.10). After some experimentation, I finally came up with what I think is a good solution. (是也乎: Django 中的模板看起来什么都能作,其实… ) 使用 BeautifulSoup 的 Web Scraping 教程 beautifulsoup In this tutorial, we’ll show you how to perform web scraping using Python 3 and the BeautifulSoup library. We’ll be scraping weather forecasts from the National Weather Service, and then analyzing them using the Pandas library. (是也乎: 国家天气局的数据抓取整理后给 美汤 分析. ) 在 Python 中构建动画 GIFs gif I first wrote a Python script to make a GIF illustration for any 5-unit color scheme. (是也乎: ) 如何通过 Pynini 在 Python 中获得卓越的文本分析能力 ? regex Regular expressions are the standard for string processing, but did you know you can often get better text untangling with Pynini’s finite-state transducers ? (是也乎: 利用 Pynini 的有限状态机来替代正则表达式来处理文本. ) CPython 内存管理 cpython This post is high level description of how CPython (just Python below) manages object life cycle. (是也乎: 在冯机框架之内, 执行效率总是得面对内存这一物理结构的额外问题 ) 针对 Python 3 的案例 python3 “There is high probability that Python 3 is such a failure it will kill Python” - Zed Shaw. As Curator of a Python Newsletter for 2+ years I can tell you at-least 20-30% of all articles I read of late have code written only for Python 3. Just recently I was at Pycon India and met lot of student who never wrote a single line in 2.x. Startup founders starting with new development choosing Python 3. Lot of people are sleeping on Python 3. A year more and hopefully everyone will be awake. (是也乎: 全球只有印度沉浸在 Py 3 的世界中..嗯哼,为什么?! 何况 Py 3 不是图灵完备的… ) 用 Python 进行研究 - 哈佛大学课程 - edx course, mooc Take your introductory knowledge of Python programming to the next level and learn how to use Python 3 for your research. You will learn Python 3 programming basics, Python tools (e.g., NumPy and SciPy modules) for research applications, How to apply Python research tools in practical settings. (是也乎: 介绍学界在 py 3 生态中如何进行研究 ) 在 Django 网站上水印图像 pillow, watermarking Have you ever noticed how stock photography sites add watermarks to the images shown on their catalogs ? They do that to make sure people don’t just take the free samples and use them without proper licensing. Turns out this is pretty easy to do it with Pillow. 元编程和 Django - 使用 Decorators django, decorators The article starts of with an introduction snippet to decorators and then goes on to explore some real world examples in context of Django. Personally one good find in the article was boltons library. JIRA 软件 Sponsor Start a free JIRA Software trial and get this shirt. (是也乎: 收购 bitbucekt.org 的靠谱软件管理开发商. ) 好物 ~ 包/模块/库/片段… ...

2016-11-23 · 4 min · 1957 words · ZoomQuiet

蠎加载 99

原文: Import Python Weekly Newsletter - Issue No 99 欢迎, 来 PyChina/weekly 共同翻译/增订/推荐 周刊 蠎消息 ;-) 该读 ~ 文章, Blog, 教程… 因长期运行而使用困难的数据如何激活在 Python core-python Jeff Knupp author of one of my favorite Python books “Writing Idiomatic Python” talks why Python is terrible for writing long-lived programs dealing with complicated data structures. He then goes to compare it with Go Programming languages where the datatype and data modeling has to be done before hand ( we are talking about complex nested data structures ) . Curator’s Note - If you are interested in golang do check out http://importgolang.com a weekly go programming newsletter. (是也乎: 当然的,和 golang 进行了对比,然后… ) Email API from SendGrid Sponsor Reliably deliver your emails with a quick and simple API or SMTP integration. Try for Free. Curator’s Note - Python and Django integration for sendgrid https://github.com/sendgrid/sendgrid-python and https://github.com/RyanBalfanz/django-sendgrid respectively. You can send 12,000 emails per month free. (是也乎: 一个实用的服务,值得关注的赞助商… 免费的话, 2K/月, 对小应用足够了 ) 用 Python 开发可扩展应用 scalability David Rodriguez attended the Udacity course: Developing Scalable Apps in Python - App Engine course and took these notes on building scalable apps. (是也乎: 可扩展应用本质上是个架构而不是语言问题… 当然,笔记在 docs.google 中,嗯哼. ) 用 Splinter 在 Python 中自动化 Web 测试 testing, automation Splinter is just an abstraction layer on top of Selenium and makes easy to write automation tests for web applications. This is a brief introduction to Splinter. (是也乎: 测试呢,最终还是得统一为 DSL, 当然,如果这个 DSL 和目标程序使用的相同,是最好的了. ) 命令行上的 HTTP 响应后端 code snippet httstat https://github.com/reorx/httpstat provides a HTTP response breakdown on command line. This saves you having to open up a browser and look at a visual network response waterfall. (是也乎: 目测是一个现成的无头浏览器的值守? ) 命令行上高速 Django 开发技巧 django David shares his list of command line alias for Django development. Curator’s note - Caution making alias for dot and double dot. keyboard opensource project Take full control of your keyboard with this small Python library. Hook global events, register hotkeys, simulate key presses and much more. (是也乎: PyHook 之后, 又一键盘控制模块,期望是跨平台兼容的…嗯哼,可怜的 M$ ) Monkey-patching 又一 Python 实例方案 core-python, monkey patching Dynamically adding or overwriting an instance method in Python is rarely needed, but it’s a good excuse to explore interesting aspects of the language that aren’t always well known: the descriptor protocol, types.MethodType and partial function applications. (是也乎: 猴补丁 ~ 方便了程序猿,逼死编译器的好物,令 Py 的加速大业又多一层壁垒 ) Django Model Managers django, models Model Managers (and custom QuerySets) are really useful. If you find yourself doing some complicated queryset logic over and over again, you can put that logic in one place and just refer to it with a simple name. (是也乎: 对于死也只用 SQL 的人来说,不存在哪… ) Django 在 instagram - Carl Meyer django, video Instagram operates at a scale unprecedented and is one of the largest users of Python/Django. In this video Carl talks about Django usage @instagram . What modification they made to Django and Why ?, How Django usage evolved over the years at instagram and more. 用 PyCharm 通过 SSH 工作在远程机器上 pycharm This article shows us the remote interpreter feature of PyCharm. Useful for those using PyCharm and want to execute scripts on a remove machine where the environment / data resides. (是也乎: 嗯哼,这样的界面,哪儿有心思写代码哪… ) 好物 ~ 包/模块/库/片段… ...

2016-11-17 · 3 min · 1466 words · ZoomQuiet