piglei's recent timeline updates
piglei's repos on GitHub
7211 watchers
one-python-craftsman
来自一位 Pythonista 的编程经验分享,内容涵盖编码技巧、最佳实践与思维模式等方面。
Python · 994 watchers
ai-vocabulary-builder
An AI-powered smart vocabulary tool with features like One-click vocabulary building and story-based memorization.
Python · 241 watchers
the-python-craftsman-book
Source code of the examples in the book "The Python Craftsman: Best Practices and Techniques by Example"
Python · 209 watchers
uwsgi-sloth
Realtime uwsgi log file analyzer, slow requests analyzer.
JavaScript · 127 watchers
fmx163
一个简单的Chrome插件来帮助你轻松享受高品质的豆瓣FM
Python · 50 watchers
django-qiniu
Qiniu(http://www.qiniu.com) is a cloud storage service, this package interages it with django framework.
Python · 27 watchers
zkpython_example
A simple example using zkpython
Python · 19 watchers
pycronic
A crontab script wrapper written in python
Python · 19 watchers
tieba_poster
Simple tieba poster
Go · 15 watchers
lbssh
Tool for filter and quick ssh into servers.
8 watchers
modularization-examples
如何复用一套代码满足多样化的需求?
Python · 8 watchers
python-qqoauth2
python sdk for qq oauth2 (http://opensns.qq.com/)
Python · 8 watchers
sshhelper
shhhelper is a simple script which helps you ssh into your machines conveniently.
3 watchers
piglei
My personal profile
JavaScript · 2 watchers
bootstrap
HTML, CSS, and JS toolkit from Twitter
Python · 1 watchers
asyncmongo
An asynchronous library for accessing mongo with tornado.ioloop
1 watchers
awesome-django
A curated list of awesome Django apps, projects and resources.
Python · 1 watchers
bkpaas-python-sdk
蓝鲸 PaaS 平台 Python 工具集
Go · 1 watchers
blueking-apigateway-operator
蓝鲸 API 网关 - Operator
Python · 1 watchers
blueking-paas
蓝鲸智云PaaS平台是一个开放式的开发平台,让开发者可以方便快捷地创建、开发、部署和管理 SaaS 应用。它提供了完善的前后台开发框架、服务总线(ESB)、API Gateway、调度引擎、公共组件 等服务。旨在帮助用户快速、低成本的构建免运维运营系统与支撑工具。
Python · 1 watchers
bscp-python-sdk
bscp-python-sdk 是蓝鲸 BSCP 项目的 Python SDK,它能帮助你轻松访问项目保存在 BSCP 上的配置内容。
1 watchers
python-base
Lua · 0 watchers
apisix
The Cloud-Native API Gateway
Python · 0 watchers
attrs
Python Classes Without Boilerplate
Python · 0 watchers
bk-bcs-saas
蓝鲸智云容器管理平台SaaS(Blueking Container Service)
Python · 0 watchers
blueking-apigateway
蓝鲸 API 网关(API Gateway),是一种高性能、高可用的 API 托管服务
Lua · 0 watchers
blueking-apigateway-apisix
蓝鲸 API 网关 - 数据面
0 watchers
bub
Bub it. Build it. A common shape for agents that live alongside people.
Python · 0 watchers
celery
Distributed Task Queue (development branch)
0 watchers
chatgpt-on-wechat
Wechat robot based on ChatGPT, which using OpenAI api and itchat library. 使用ChatGPT搭建微信聊天机器人,基于GPT3.5 API和itchat实现
Python · 0 watchers
django-bootstrap-form
Twitter Bootstrap for Django Form
0 watchers
django-revproxy
Reverse Proxy view that supports all HTTP methods, Diazo transformations and Single Sign-On.
Python · 0 watchers
django-storages
0 watchers
docs
User documentation for Knative components.
Python · 0 watchers
dynaconf
Configuration Management for Python ⚙
Go · 0 watchers
flannel
flannel is a network fabric for containers, designed for Kubernetes
Python · 0 watchers
geventhttpclient
A high performance, concurrent http client library for python with gevent
0 watchers
import-linter
Import Linter allows you to define and enforce rules for the internal and external imports within your Python project.
Go · 0 watchers
kapacitor
Open source framework for processing, monitoring, and alerting on time series data
0 watchers
mysqlclient
MySQL database connector for Python (with Python 3 support)
HTML · 0 watchers
node-js-getting-started
Getting Started with Node on Heroku
0 watchers
opc-book-comments
Repository for storing gittalk comments
0 watchers
pdm-expansions
What does PDM stand for?
0 watchers
piglei-giscus-comments
Comments for piglei.com
Python · 0 watchers
poetry
Python dependency management and packaging made easy.
Go · 0 watchers
prometheus-operator
Prometheus Operator creates/configures/manages Prometheus clusters atop Kubernetes
Python · 0 watchers
pyspider
A Powerful Spider(Web Crawler) System in Python.
Python · 0 watchers
Python-Type-Challenges
Master Python typing (type hints) with interactive online exercises!
Python · 0 watchers
qcloudapi-sdk-python
Tencent Cloud SDK for Python
0 watchers
republic
Build LLM workflows like normal Python while keeping a full audit trail by default.
0 watchers
rich
Rich is a Python library for rich text and beautiful formatting in the terminal.
JavaScript · 0 watchers
RSSHub-pub
🍰 Everything is RSSible
Rust · 0 watchers
rust-course
“连续六年成为全世界最受喜爱的语言,无 GC 也无需手动内存管理、极高的性能和安全性、过程/OO/函数式编程、优秀的包管理、JS 未来基石" — 工作之余的第二语言来试试 Rust 吧。<<Rust语言圣经>>拥有全面且深入的讲解、生动贴切的示例、德芙般丝滑的内容,甚至还有JS程序员关注的 WASM 和 Deno 等专题。这可能是目前最用心的 Rust 中文学习教程/书籍
Go · 0 watchers
telegraf
The plugin-driven server agent for collecting & reporting metrics.
0 watchers
website
Kubernetes website and documentation repo:
Python · 0 watchers
wemake-python-styleguide
The strictest and most opinionated python linter ever!
CSS · 0 watchers
workflow
Deis Workflow, an open source Kubernetes PaaS.
piglei

piglei

Yet Another Pythonista
🏢  Tencent
V2EX member #45802, joined on 2013-09-22 18:00:41 +08:00
Python 工匠:写好面向对象代码的原则(上)
  •  1   
    Python  •  piglei  •  Jul 1, 2019  •  Lastly replied by piglei
    6
    Python 工匠:高效操作文件的三个建议
  •  1   
    Python  •  piglei  •  Jun 18, 2019  •  Lastly replied by piglei
    18
    Python 工匠:做一个精通规则的玩家
  •  4   
    Python  •  piglei  •  May 28, 2019  •  Lastly replied by xuanwu
    9
    Python 工匠:编写地道循环的两个建议
    Python  •  piglei  •  Apr 30, 2019  •  Lastly replied by bwangel
    29
    [深圳] 腾讯游戏运营部 PaaS 平台招聘 Python 后台工程师
  •  1   
    酷工作  •  piglei  •  Oct 13, 2016  •  Lastly replied by ihacku
    12
    piglei's recent replies
    Jan 26, 2025
    Replied to a topic by shinonome Python 《 Python 工匠》中多态的使用有一些疑惑
    > 但是在我看来, 你要传什么 output_writer 不还是要通过 if 来选择吗, 只是把一个地方的 if 换到了另外一个地方,

    你的理解已经很接近:“多态”确实无法完全消除“if”。这是因为,人们总是需要用代码来表达某种“如果/否则”的逻辑。但和普通的“if/else”比起来,面向对象设计的区别在于,它会努力将这些“如果/否则”逻辑封装在不同的实现(`XWriter`)中,让“if/else”代码只存活于代码的边缘区(工厂函数),从核心区中销声匿迹。

    什么是核心区?显而易见,是 FancyLogger 中实际完成日志打印的部分;什么是边缘区?在例子中,用 if/else 分支去创建对应的 Writer 实例的代码,前置于打印日志功能,可以被看作身处边缘区。对比例子中的两种方式:

    1. 无 Writer 抽象时:核心区需要理解**全部的“如果/否则”逻辑**,才能完成日志打印
    2. 有 Writer 抽象时:在边缘区创建 writer 实例,传递给核心区,后者**一视同仁**调用 writer 完成日志打印

    本书中的代码示例,因篇幅原因实现的功能比较简单,不同代码之间所产生的对比可能不够强烈。当业务逻辑变得更复杂后,利用多态特性来提炼并封装“如果/否则”的优势会变得更显著。在我心目中,那是在整个“面向对象”中,最富有魅力的地方之一。
    Aug 12, 2022
    Replied to a topic by ppj Python Python 每日一练:等分字符串
    好答案前面有了,我再多贡献一条基于正则的花活。若干年前学自《精通正则表达式》,对于当时的我过于震撼,牢记至今:

    >>> s = 'F0B42998CE34'
    >>> import re
    >>> re.sub(r'(?<=.)(?=(..)+$)', '-', s)
    'F0-B4-29-98-CE-34'
    @QuinceyWu @weihuilee @dearmymy @charexcalibur 感谢你们的支持。
    @toan 问了出版方,还没有确定的答复 :(
    @psyer 不是一类风格,不太好对比,建议简单试读后自己判断是否适合。
    @root01 可以先看试读章节与开源文章,够你读一阵了。
    @lion9527 @ClericPy @tfull @dream4ever @ice2016 @Freya21 @Elaina @fx0719 @yaron @v2exblog 感谢对书的认可和支持。
    @devtiange
    @upojzsb 电子版昨天刚在图灵社区上架(仅 mobi 格式): https://www.ituring.com.cn/book/3007 ,欢迎了解。
    @LeeReamond 感谢建议,起标题时没多想,抱歉引起了您的误解。《流畅的 Python 》是一本非常棒的经典之作,内容既有深度,也十分全面,拙作在这些方面的确难以望其项背。但作为一本书,阅读价值是因人而异的。对于那些刚迈过新手阶段不久,苦恼于自身代码质量的程序员,我认为《 Python 工匠》里的经验之谈确实能为其提供一些帮助。感谢您的指点。
    @wklken 感谢。
    @chi1st 感谢支持。我字丑,你就当我用意念给你签过了吧,祝你读得开心。
    Jun 9, 2022
    Replied to a topic by acctv2 Python 有没有一些高质量的 Python 内容推荐?
    我写了本 Python 进阶相关的书:[《 Python 工匠:案例、技巧与工程实践》 ]( https://www.zlovezl.cn/book/index.html),今年三月份出版。内容主要是一些编写高质量代码的技巧及工程实践建议,感兴趣的话可以试读了解一下。

    - 试读样章: https://www.zlovezl.cn/book/index.html
    - 豆瓣书评: https://book.douban.com/subject/35723705/
    - 京东购买: https://item.jd.com/13068111.html

    ---

    《 Python 工匠》是一本以 Python 进阶编程为主题的技术图书。纸质书由人民邮电出版社于 2022 年出版,与其他同类图书相比,《 Python 工匠》有着以下突出特色:

    - 专注于基础编程素养与 Python 高级技巧的结合
    - 内容深入 Python 语言内核,不浮于表面
    - 知识点都由作者精心挑选过,而非罗列官方文档
    - 通过有趣的“案例故事”表达有用的编程理念
    支持(从没见过你描述里的那么详细的需求文档)
    Dec 25, 2020
    Replied to a topic by jimmyismagic 阅读 影响你最深的一本书是什么?
    《代码大全 第二版》
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5483 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 44ms · UTC 07:02 · PVG 15:02 · LAX 00:02 · JFK 03:02
    ♥ Do have faith in what you're doing.