Gunicorn & LRU cache pitfall
Gunicorn & LRU pitfall In python 3 you can use decorator @lru_cache from functools module. It stores a result of decorated function inside the cache. Imagine that you have simple flask application:...
View ArticlePython字符串拼接方法详解
python字符串拼接方法详解 一点号python开源学院1小时前 字符串是python中最常用的一种数据类型,字符串的拼接方法有很多种,这里将通过例子来详细讲解这几方法的使用及各自的特点。 >>> a = 'hello' >>> b = 'python' >>> c = '!' >>> a + ' ' + b + ' ' +...
View ArticleDoing query param request in Django
Typically, I want my API endpoint url to be flat like this: mydomain.com/shit_api/v1/person/123 That url is pretty straight forward, it's trying to get a person with an ID of 123 from shit_api. But...
View ArticleDjango Dynamic Formsets
Django forms are one of the most important parts of the stack: they enable us to write declarative code that will validate user input, and ensure we protect ourselves from malicious input. Formsets are...
View ArticleExtracting a TOC from Markup
In today’s addition of “really simple things that come in handy all the time” I present a simple script to extract the table of contents from markdown or asciidoc files: So this is pretty simple, just...
View ArticleRec-a-Sketch: a Flask App for Interactive Sketchfab Recommendations
After the longseries of previous posts describing various recommendation algorithms using Sketchfab data, I decided to build a website called Rec-a-Sketch which visualizes the different algorithms'...
View Article码云推荐 | 基于 ActiveRecord 模式的 ORM 框架 Hare
Hare hare 是一个基于pymysql并运用ActiveRecord模式的ORM框架, 在虚拟环境下,通过: pip install hare 即可安装。 当前,它只支持: MySQL 动机 在python下进行数据库操作, 大体有两种方法: 1、使用raw sql 2、使用ORM Raw SQL python中常用的 raw sql 工具是: MySQLdb PyMySQL 使用 raw...
View ArticleVisual Studio 2017 RC3支持.NET Core,延迟对Python的支持
Visual Studio 2017第三个候选版本上周发布,解决了之前发现的安装程序的小问题。由于这些问题得到了解决,现在值得关注的就是这次版本中更新了什么内容。(版本是发布于1月27日的build 26127.00) RC3版本中最值得关注的部分就是对NET.Core和ASP.NET Core的支持,对Team Explorer的更新以及对Visual...
View Article(原创)我为什么要学Python
写文章也有一段时间了,感觉每篇文章前面加上 (原创) 两个字有点土,但突然不加 (原创) 又怕看官觉得是不是哪抄袭过来的,真是纠结。纠结归纠结,还是应该有一个了结, (原创) 在下一篇文章之后就不加在标题上了,之后的原创申明会放在文末,望知悉。(一bu小心加粗了三个 (原创) ,望谅解[坏笑脸]) 回...
View ArticlePython 表达式 i += x 与 i = i + x 等价吗?
题图:unsplash.com by Dmitry Pavlov python 表达式 i += x 与 i = i + x 等价吗?如果你的回答是yes,那么恭喜你正确了50%,为什么说只对了一半呢? 按照我们的一般理解它们俩是等价的,整数操作时两者没什么异同,但是对于列表操作,是不是也一样呢?先看下面两段代码: 代码1 >>> l1 = range(3)...
View Articlepython generators, coroutines, native coroutines and async/await
Abstraction is not about vagueness, it is about being precise at a new semantic level. - Dijkstra 笔者之前学习python的时候就对这几个概念有些困惑,尤其是python3之后又不断添加了 yield from, async, await...
View Article注意迁移的PyTorch实现
本项目是论文《要更加注重注意力:通过注意迁移技术提升卷积神经网络的性能(Paying More Attention to Attention: Improving the Performance of Convolutional Neural Networks via Attention Transfer)》PyTorch 实现。点击文末「阅读原文」可查阅原论文。...
View Articlenvim-completion-manager - A completion framework for neovim
:heart: for my favorite editor A Completion Framework for Neovim This is my experimental completion framework for neovim, which offers great flexibility for writing your own completion plugin,...
View ArticlePython之路【第二十二章】:Django Form组件
Form组件 Django的Form主要具有一下几大功能: 生成HTML标签 验证用户数据(显示错误信息) HTML Form提交保留上次提交数据 初始化页面显示内容 创建Form类时,主要涉及到 【字段】 和 【插件】,字段用于对用户请求数据的验证,插件用于自动生成HTML; 1、内置字段 Field required=True, 是否允许为空 widget=None, HTML插件...
View ArticleYes, People Still Want to Learn Excel
A question I getall the time:“Why do you blog about Excel? R/python/name your program is better.” There’s no doubt that Microsoft is facing increased competition in the business analytics market....
View Article0016 编程入门python之模块和进程
0016 编程入门python之模块和进程 一点号零基础学编程14分钟前 php?url=0FaU0Cahb8" alt="0016 编程入门python之模块和进程" /> 上节课作业 1.修改输入一个年月日日期,输出是星期几的程序,闰年判断做成函数,统计天数作成函数,星期计算做成函数 代码如下: 2.求图形面积函数增加平行四边形,梯形 做成模块...
View Article隔壁程序员是这样教我学Python Web的
隔壁程序员是这样教我学python Web的 一点号CSDN3小时前 系列直播 Python除了可以写虫、做数据挖掘,我们也可以使用Python进行WEB开发,使用Python进行WEB开发将会让代码非常简洁,并且后续也比较易于维护,本课程将由CSDN与韦玮老师联合推出,在这一门课程中,将使用Python3一步一步讲解WEB开发的知识,并且全程采用实战案例教学,让学员可以从实际场景中学习Python...
View Articledjango signal 使用总结
最近在已经开发好的项目上加功能,想到了django的signal,整理记录如下备查。 什么是django的signal 官方文档描述如下: Django includes a “signal dispatcher” which helps allow decoupled applications get notified when actions occur elsewhere in the...
View ArticleHow to fix Django’s HTTPS redirects in nginx
In the nginx configuration (inside the location block), specify this: proxy_redirect off; proxy_set_header X-Forwarded-Proto $scheme; The proxy_redirect off statement tells nginx that, if the backend...
View ArticleHow to plot your own bike/jogging route using Python and Google Maps API
Apart from being a data scientist, I also spend a lot of time on my bike. It is therefore no surprise that I am a huge fan of all kinds of wearable devices. Lots of the times though, I get quite...
View Article