首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

五个提高您工作效率的Python开发设置技巧——我桥AI三月Python文章Top10之三

数据简化DataSimp导读:为专业人士提供文章排名服务Mybridge AI(https://www.mybridge.co/)通过综合考虑分享的总数量、阅读时间,用机器学习算法对3月近1000篇关于Python的文章进行排名(2018.3),挑选了其中最好10篇(1%的概率),发现Python领导者所共享的经验和技术是有用的。话题包括:数据科学、Dash、小技巧、Django、性能、比特币、教程、音乐、软件公司、命令行;可以在Github(https://github.com/Mybridge/python-articles)上关注Mybridge AI每月十篇关于Python最火文章,并且每月会收到一封邮件。

上期介绍No1《Python是解决任何问题最好的工具》作者William Koehrsen链接https://medium.com/@williamkoehrsen。这期继续看No2《简介—数据可视化图形界面工具Dash以及Python p.1》作者Sentdex链接:https://www.youtube.com/watch?v=J_Cy_QjG6NE;第三名《5个提高您工作效率的Python开发设置技巧》作者Dan Bader链接:https://medium.com/@dbader_org。数据简化社区翻译的汉译文,版权归原作者所有。

01No3.五个提高您工作效率的Python开发设置技巧(2943字)

5个提高您工作效率的Python开发设置技巧

作为一个新的Python开发人员,我努力建立一个有效的开发环境。要建立正确的习惯和找到一套我喜欢使用的工具是很困难的。

当时我不明白这对我的工作效率有多大影响。我甚至不知道我今天使用的一些最有价值的实践和工具的存在!

随着经验的增加,我知道这是Python开发人员常见的痛苦。无论我与谁交谈——同事、会议上的陌生人,或是论坛和邮件列表上的开发人员——我都看到了类似的挣扎。

今天,我相信Python程序员新手可以在他们的工作流程中采用一些关键的措施和工具来提高他们的生产力。

本文帮助您识别和修复Python开发设置中的5个常见问题。这些我都经历过,在某些情况下,我是同事和团队的领导者。如果您能够避免这些问题,您将成为更快乐、更有效的Python开发人员。

1——不要浪费时间做编译器的工作

当开发人员的大脑做计算机大脑能做的更好的事情时,这通常是一个代价高昂的错误。一个例子是程序员花费时间寻找bug,而这些bug其实可以通过自动化工具来发现。

出于某种原因,可能是因为Python的动态特性和作为“脚本”语言的早期状态,所以很少看到它使用静态代码分析工具和链接器。

但是这些工具非常棒。它们完全可以帮助检测和避免某些bug和类错误。例如,他们可以捕获拼写错误的标识符,或者显示代码质量问题,比如未使用的变量和导入。

我不会说代码分析工具是一种神奇的解决方法——但是它们可以帮助减少调试和代码评审时间。

如果您正在寻找一个能够提高Python代码质量的工具,而且不需要错误信息和冗长的消息,那么我将推荐pyflakes。pyflakes是开源的,可以免费使用,并且易于设置。

为了得到及时的反馈并及时发现bug,我建议您将pyflakes与代码编辑器集成在一起,并构建服务器。作为持续集成过程的一部分,自动地进行代码更改将使您的生活更轻松。它确保您的团队中所有的开发人员都使用相同的设置,并且没有任何未捕获的警告通过

小技巧1:使用像pyflakes这样的静态代码分析工具

2——避免毫无结果的代码风格讨论

您的团队进行代码评审?太棒了!但是请注意,在没有经验的代码评审员中,一个常见的错误是花太多时间在自动化工具可以提供的反馈上。我说的是代码风格问题。

开发团队很容易养成习惯,在代码评审中讨论代码风格的问题:“这里需要一个空格”或者“类名应该使用驼峰命名方式。”

这是一种防止开发人员关注到真正的问题的障碍。这会浪费金钱并导致维护问题。

有一个快速解决方案是选择网上的Python风格指南,比如PEP 8或Google的Python风格指南,并将自动化工具放在适当的位置,确保提交的代码遵循这个风格指南。

我建议使用PEP 8作为风格指南,并与Pycodestyle或flake8代码风格检查器结合使用。这将有助于避免大多数代码风格的讨论,并允许您的团队关注那些重要的问题。

小技巧2:选择一个代码风格(PEP 8)并使用自动化工具执行它。

3——微小的延迟和千刀万剐的死机

可用性研究表明,网站页面加载时间对用户的留存有很大影响:如果人们厌烦了等待发生的事情,就会增加他们放弃原来的任务的可能性。

作为软件开发人员,等待工具完成他们的工作是我们日常工作流程的正常组成部分。我们总是等待一个模块的安装,一个运行的测试,或者一个提交完成的任务(“它正在编译!”)。当然,我们不是每次都要“放弃”我们的工作——我们必须等上几秒钟才能运行一个工具——把注意力集中在手头的任务上是我们工作的一部分。

然而,保持这样的专注会消耗我们在其他工作领域的精神能量:我们在下午会更快地感到疲惫,或者在我们的最新提交的代码中带着一个小小的bug。

根据我的经验,即使是很小的被迫暂停延迟也会增加。在慢速的编辑器中切换文件或者在慢速计算机之间切换应用程序是令人沮丧的!甚至更微观的层面,比如编辑器输入延迟。我相信这些微小的延迟也会累积起来。它们让我们付出了代价,并导致了挫败感。

有时间做一个小的思想实验吗?比如说,你在等待一项任务完成,每10秒钟就有1秒延迟。这就意味着每周有半天的时间,或者一个月的2天,或者一年内失去了一个月的工作时间。

也许这个估计太高了——但是如果你能在一个下午的时间里花一个下午的时间来优化你的工具,你会怎样呢?我觉得这值得一试!

小技巧3:你的开发工具应该是快速的。崇尚简单。

4——不要在不愉快的编辑环境下工作

使用那些我不喜欢的工具来破坏我的工作效率。你可能知道这种感觉。有些工具会让你很沮丧,它们会降低你的能量水平和动力。

作为一名开发人员,你每天工作的最重要的工具是什么?对我来说,这是我的代码编辑器。对于一些开发人员来说,这可能是他们的电子邮件客户端或者团队聊天应用——但是我们希望你一天的大部分时间都花在编写代码上。

这就意味着,它可以从生产力(和幸福)的角度来投资于一个令人愉快的代码编辑环境。

作为Python开发人员,我们有许多编辑器和IDE可供选择:Vim、Emacs、PyCharm、Wing IDE、Atom、Eclipse PyDev、Sublime——只是举几个例子。

多年来,我花了很多时间来调整我的编辑环境。在尝试了其他编辑ide之后,我最终选择了Sublime。我喜欢它的速度、简单性和稳定性。我觉得我的编程工作流程是正确的。我通过尽可能多的选择来做出这个选择。

你的选择可能不同。我想说的是,你需要找出哪种工具最适合你自己和你的独特需求。去试试一些编辑器,看看你最喜欢哪一个。你的工作效率会因此而感谢你。

小技巧4:找到合适的编辑器并根据需要调整它。

5——投资于你的设置

我曾经和一个使用商业编辑器编写代码的人一起工作。但是那个开发者并不想花钱去购买它的许可证。相反,他们用了几个月的试用版编辑器。

这个特定编辑器的试用版有一个唠叨的屏幕,每隔几分钟就会弹出一个文件,请求您购买完整版本。这个开发人员不断地从习惯中保存文件,因此每天都要看到那个唠叨的屏幕数百次。

一份移除这个弹窗的费约为70美元。我喜欢节俭的心态,但试图在你整天使用的关键工具上省钱是一个错误的选择——我敢肯定,那些唠叨的屏幕和他们所造成的微妙的挫折加起来导致了超过70美元的生产力损失。

如果你是为自己工作,那么这些许可证费用将是你可以从税款中扣除的商业费用。如果你在一家公司工作,我相信他们会很乐意投资你的工具,如果你解释他们如何让你的工作更有效率,更有价值。

例如,软件开发工具的许可证成本与图形设计师或架构师所必须忍受的相比是低的。一些最好的工具和编辑器甚至可以免费使用。把钱投资在合适的工具上,这样你的生活(和事业)就会变得更好。

小技巧5:投资那些能让你快乐和有效的工具。

从哪里开始?

我向您展示了五个常见的开发设置问题,这些问题可能会损害您作为Python程序员的生产力。幸运的是,他们中的大多数都很容易用正确的方法解决:

技巧1:使用像Pyflakes这样的静态代码分析工具。

技巧2:选择一个代码风格(PEP 8)并使用自动化工具执行它。

技巧3:你的开发工具应该是快速的。崇尚简单。

技巧4:找到合适的编辑器并根据需要调整它。

技巧5:投资那些能让你快乐和有效的工具。

这里有个好方法:找出最让你感到恼火的问题。你会想要分而治之,而不是试图立即达到完美。一次只做一件小事。然后进行迭代并不断改进。

把它看作是一种投资——即使是很小的改变也会随着时间的推移而增加,并且会给你带来长期的生产力收益。以我的经验,成功就是建立正确的习惯和不断改进的心态。

一个好的开发环境会让你感到自信和富有成效。当你在你的设置程序中感到自在时,Python会变得更加有趣和有趣。祝你好运!

2No3. 5 Python Development Setup Tips to Boost Your Productivity(1783字)

https://dbader.org/blog/python-development-setup-tips-to-boost-your-productivity?utm_source=mybridge&utm_medium=blog&utm_campaign=read_more

原文:

5 Python Development Setup Tips to Boost Your Productivity

I struggled with setting up an effective development environment as a new Python developer. It was difficult to build the right habits and to find a set of tools I enjoyed to use.

Back then I didn’t understand how much this impacted my productivity. I didn’t even know some of the most valuable practices and tools I’m using today existed!

As my experience grew I understood this was a common pain among Python developers. No matter who I spoke with—colleagues, strangers at a conference, or developers on web forums and mailing lists—I saw similar struggles.

Today I believe entry-level Python programmers can make leaps in their productivity by adopting a few key practices and tools into their workflow.

This article helps you identify and fix 5 common issues in your Python development setup. I experienced them all myself and in some cases helped others through them as a colleague and a team lead. If you can avoid these issues you’ll become a happier and more effective Python developer.

#1 – Don’t waste time doing the compiler’s job

When developer brains do what computer brains can do much better then that’s usually a costly mistake. One example is programmers spending time hunting bugs that could be spotted just as well by automated tools.

For some reason, maybe because of Python’s dynamic nature and earlier status as a “scripting” language, it’s still rare to see it used with static code analysis tools and linters.

But these tools are fantastic. They can help detect and avoid certain bugs and classes of errors completely. For example, they can catch functional bugs like misspelled identifiers or reveal code quality issues like unused variables and imports.

I won’t say code analysis tools are a miracle cure—but they can help reduce debugging and code review time with a small initial time investment.

If you’re looking for just one tool that will improve the quality of your Python code without getting in the way with false positives and verbose messages, then I’d recommend thePyflakescode linter. Pyflakes is open-source, available for free, and easy to set up.

To get immediate feedback and catch bugs early I recommend you integrate Pyflakes with your code editor and build server. Automatic linting for code changes as part of your continuous integration process makes your life easier. It ensures all developers on your team use the same settings and no uncaught warnings slip through the cracks.

Tip 1: Use static code analysis tools like Pyflakes.

#2 – Avoid fruitless code style discussions

Your team does code reviews? Great! But be aware that a common mistake among inexperienced code reviewers is to spend too much time on feedback that automated tools could give for them. I’m talking about code style issues.

It’s easy for development teams to get into a habit where they mostly talk about code style issues in code reviews: “We need an extra space character here.” or “Class names should use camel case.”

This is a form of bikeshedding that prevents developers from looking at the real issues. The ones that cost money and cause maintenance problems later on.

A quick fix here is to pick one of the Python style guides available on the internet, likePEP 8orGoogle’s Python Style Guide, and to put automated tools in place that make sure committed code follows the style guide.

I recommend usingPEP 8as a style guide in combination with thePycodestyleorflake8code style checker. This will help avoid most code style discussions and allows your team to focus on the issues that matter.

Tip 2: Pick a code style (PEP 8) and enforce it with automated tools.

#3 – Micro delays and death by a thousand cuts

Usability research shows the large effect website page load time has onuser abandonment: If people get bored waiting for something to happen it increases the chances that they’ll abandon the original task they had in mind.

As software developers, waiting on tools to complete their job is a normal part of our day to day workflow. We’re always waiting for a module to install, a test to run, or a commit to finish (“It’s compiling!”). Of course we’re not “abandoning” our work every time we have to wait a few seconds for a tool to run—keeping focused on the task at hand is part of our job after all.

Yet, keeping that focus costs mental energy that we might then lack in other areas of our work: We get tired a little quicker in the afternoon, or introduce a tiny little extra bug with our latest commit.

In my experience even small forced pauses and delays add up. Switching files in a slow editor or jumping between apps on a slow computer is frustrating! We can even apply this at a microscopic level and look intoeditor typing latencies. I believe these micro delays add up, too. They cost us productivity and cause frustration.

Got time for a little thought experiment? Let’s say you’re waiting for a task to complete for about 1 out of every 10 seconds you spend on productive work. That adds up to half a day per week, or 2 days a month, or a whole month of productive work you might be losing over the course of a year.

Maybe this estimate is too high—but what if you could get an additional week of productive time a year just by spending an afternoon on optimizing your tools? I’d say that’s worth a try!

Tip 3: Your development tools should be fast. Favor simplicity.

#4 – Don’t work with an unpleasant editing environment

Working with tools that I don’t enjoy crushes my productivity. You might know the feeling. Some tools are so frustrating to work with they zap your energy levels and motivation.

What’s the most important tool that you work with every day as a developer? For me it’s my code editor. For some developers it might be their email client or a team chat app—but let’s hope that a large part of your day is spent writing code.

This means it pays off in terms of productivity (and happiness!) to invest into an enjoyable code editing environment.

As Python developers we have many editors and IDEs to choose from:Vim,Emacs,PyCharm,Wing IDE,Atom,Eclipse PyDev,Sublime Text—just to name a few.

I spent much time fine-tuning my editing environment over the years. After trying other editors and IDEs Ieventually settled on Sublime Text. I like its speed, simplicity, and stability. It just feels right for my programming workflow. And I arrived at this choice by trying as many other options as I could.

Your choice might be different. The point I’m trying to make is you need to find out which tool works best for yourself and your unique needs. Go and try out some editors and see which one you enjoy the most. Your productivity will thank you for it.

Tip 4: Find the right editor and tailor it to your needs.

#5 – Invest in your setup

I once worked with someone who used a commercial editor to write code. But that developer didn’t want to spend the money to purchase a license for it. Instead they used the trial version of the editor for months on end.

The trial version of this particular editor has a nag screen that pops up every few minutes when you save a file, asking you to buy the full version. This developer constantly saved files out of habit and therefore got to see that nag screen hundreds of times a day…

A license that would’ve removed the nag screen cost about $70. I love a frugal mindset but this was ridiculous! Trying to save some money on a critical tool you use all day was the wrong choice—I’m sure the nag screens and the subtle frustrations they caused added up to more than $70 of lost productivity.

If you’re working for yourself then these license costs will be a business expense you can deduct from your taxes. If you’re working for a company I’m sure they’ll gladly invest in your tools if you explain how they make you more productive and more valuable as an employee.

License costs for software development tools are low compared to what graphic designers or architects have to put up with, for example. Some of the best tools and editors are even available for free. Invest money in the right tools where it makes sense and your life (and career) will be better for it.

Tip 5: Invest in tools that make you happy and more effective.

Where to start?

I showed you five common development setup issues that can harm your productivity as a Python programmer. Luckily most of them are easy to fix with the right approach:

·Tip 1: Use static code analysis tools like Pyflakes.

·Tip 2: Pick a code style (PEP 8) and enforce it with automated tools.

·Tip 3: Your development tools should be fast. Favor simplicity.

·Tip 4: Find the right editor and tailor it to your needs.

·Tip 5: Invest in tools that make you happy and more effective.

Here’s a good way to start: Find the one problem that irritates you the most. You’ll want todivide and conquerinstead of trying to achieve perfection immediately. Fix one small thing at a time. Then iterate and keep making improvements from there.

Think of it as an investment—even small changes will compound over time and give you a nice long-term productivity gain. In my experience, success is all about building the right habits and a mindset of continuous improvement.

A great development environment makes you feel confident and productive. When you feel right at home in your setup programming Python becomes even more enjoyable and fun. Good luck!

(This article was originally published onTechBeacon.)

-END-

参考文献(116字)

1.Mybridge AI.python top 10 articles for the past month.[EB/OL]https://medium.mybridge.co/python-top-10-articles-for-the-past-month-v-mar-2018-7b60ad2b28e6,2018-03-08.

2. TechBeacon.5 Python Development Setup Tips to Boost Your Productivity.[EB/OL]https://dbader.org/blog/python-development-setup-tips-to-boost-your-productivity?utm_source=mybridge&utm_medium=blog&utm_campaign=read_more,2018-03-08.

五个提高您工作效率的Python开发设置技巧——我桥AI三月Python文章Top10之三(5058字)

简介:我桥AI对三月近1000篇Python文章进行排名(2018.3),挑选其中最好的10篇(1%概率)。数据简化社区本文翻译其第三篇《五个提高您工作效率的Python开发设置技巧》,文后附原英文。(文末“阅读原文”可下载1图3码15k字6页PDF)蓝色链接“数据简化DataSimp”关注后下方菜单项有文章分类页。作者:TechBeacon。来源:数据简化社区白鑫翻译自TechBeacon,引文出处请看参考文献。版权声明:科普文章仅供学习研究,公开资料©版权归原作者,请勿用于商业非法目的。如出处有误或侵权,请联系沟通、授权或删除事宜、投稿邮箱DataSimp@126.com。欢迎转发:“数据简化DataSimp、科学Sciences、知识简化”新媒体聚集专业领域一线研究员;研究技术时也传播知识、专业视角解释和普及科学现象和原理,展现自然社会生活之科学面。秦陇纪发起未覆盖各领域,期待您参与~

目录

五个提高您工作效率的Python开发设置技巧——我桥AI三月Python文章Top10之三(5058字)1

01No3.五个提高您工作效率的Python开发设置技巧(2943字)1

2No3. 5 Python Development Setup Tips to Boost Your Productivity(1783字)3

参考文献(116字)5

Appx(625字).数据简化DataSimp社区简介5

Appx(625字).数据简化DataSimp社区简介

信息社会之数据、信息、知识、理论持续累积,远超个人认知学习时间、精力和能力。应对大数据时代的数据爆炸、信息爆炸、知识爆炸,解决之道重在数据简化(Data Simplification):简化减少知识、媒体、社交数据,使信息、数据、知识越来越简单,符合人与设备的负荷。数据简化2018年会议(DS2018)聚焦数据简化技术(Data Simplification techniques):对各类数据从采集、处理、存储、阅读、分析、逻辑、形式等方面做简化,应用于信息及数据系统、知识工程、各类数据库、物理空间表征、生物医学数据,数学统计、自然语言处理、机器学习技术、人工智能等领域。欢迎投稿数据科学技术、简化实例相关论文提交电子版(最好有PDF格式)。填写申请表加入数据简化DataSimp社区成员,应至少一篇数据智能、编程开发IT文章:①高质量原创或翻译美欧数据科技论文;②社区网站义工或完善S圈型黑白静态和三彩色动态社区LOGO图标论文投稿、加入数据简化社区,详情访问www.datasimp.org社区网站,网站维护请投会员邮箱DataSimp@163.com。请关注公众号“数据简化DataSimp”留言,或加微信QinlongGEcai(备注:姓名/单位-职务/学校-专业/手机号),免费加入投稿群“科学Sciences学术文献”读者微信群等。长按下图“识别图中二维码”关注三个公众号(搜名称也行,关注后底部菜单有文章分类页链接):

数据技术公众号“数据简化DataSimp”:

社会教育知识公众号“知识简化”:

普及科学知识,分享到朋友圈

  • 发表于:
  • 原文链接http://kuaibao.qq.com/s/20180321G15MU100?refer=cp_1026
  • 腾讯「腾讯云开发者社区」是腾讯内容开放平台帐号(企鹅号)传播渠道之一,根据《腾讯内容开放平台服务协议》转载发布内容。
  • 如有侵权,请联系 cloudcommunity@tencent.com 删除。

扫码

添加站长 进交流群

领取专属 10元无门槛券

私享最新 技术干货

扫码加入开发者社群
领券