我学习、工作和使用Python已经有一年半的时间了。作为一名慢慢转向生物信息学的生物学家,这种语言一直是我在实验室所做的所有主要贡献的核心。我或多或少爱上了Python让我表达美丽的解决方案的方式,也爱上了这种语言的语义,它允许从思想到可行的代码的自然流动。

有一个问题,我很少在这里或其他论坛看到,我想听听你的回答。在我看来,这个问题对于任何走在Python改进道路上的人来说都很重要,但他不知道下一步应该做什么。

让我先总结一下我不想问的问题;)

我不想知道如何快速学习Python 我也不想找出熟悉这门语言的最佳方法 最后,我不想知道“一个技巧可以解决所有问题”的方法。

我想知道你的意见是:

从学徒到大师,你会向Python熟练者推荐哪些步骤,以便一个人不断提高,成为一个越来越好的Python程序员,一次一步。SO上的一些人几乎因为他们的Python能力而值得崇拜,请启发我们:)

我喜欢的那种回答(但请随意给读者惊喜:P),格式或多或少是这样的:

阅读这个(例如:python教程),注意那种细节 这么多时间/问题/行代码的代码 然后,读这本(例如:这本或那本书),但这次,注意这本 解决一些现实生活中的问题 然后,继续读取Y。 一定要掌握这些概念 X时间的代码 回到这样那样的基础或进一步讨论…… (你懂的)

我真的很想知道你对一个人在不同阶段应该注意什么问题的看法,以便不断进步(当然,要付出适当的努力)。如果你来自一个特定的专业领域,讨论一下你认为适合这个领域的道路。

编辑:感谢您的大力投入,我又回到了Python改进的轨道上!非常感谢!


当前回答

I recommend starting with something that forces you to explore the expressive power of the syntax. Python allows many different ways of writing the same functionality, but there is often a single most elegant and fastest approach. If you're used to the idioms of other languages, you might never otherwise find or accept these better ways. I spent a weekend trudging through the first 20 or so Project Euler problems and made a simple webapp with Django on Google App Engine. This will only take you from apprentice to novice, maybe, but you can then continue to making somewhat more advanced webapps and solve more advanced Project Euler problems. After a few months I went back and solved the first 20 PE problems from scratch in an hour instead of a weekend.

其他回答

如果你在科学中使用python(看起来你是这样),其中的一部分将是学习和理解科学库,对我来说,这些将是

numpy scipy matplotlib mayavi / mlab 查科 Cython

了解如何使用正确的库和向量化代码对于科学计算是至关重要的。

我想补充一点,用常见的python方式(面向对象的方法、列表、迭代器)处理大型数字数据集的效率非常低。在科学计算中,有必要以与大多数常规python编码员处理数据的方式截然不同的方式构建代码。

谷歌最近发布了一个在线Python类(“类”在“一门课程”中)。

http://code.google.com/edu/languages/google-python-class/

我知道这并不能完全回答你的问题,但我认为这是一个很好的开始!

这不是你想要的,但我觉得这是个好建议。

学另一门语言,哪门都无所谓。每种语言都有自己的想法和习惯,你可以从中学习。了解语言之间的差异,更重要的是为什么它们不同。尝试纯函数式语言,如Haskell,看看函数的一些好处(和挑战),没有副作用。看看如何将从其他语言中学到的一些东西应用到Python。

我认为掌握Python的过程是这样的:

Discover list comprehensions Discover generators Incorporate map, reduce, filter, iter, range, xrange often into your code Discover Decorators Write recursive functions, a lot Discover itertools and functools Read Real World Haskell (read free online) Rewrite all your old Python code with tons of higher order functions, recursion, and whatnot. Annoy your cubicle mates every time they present you with a Python class. Claim it could be "better" implemented as a dictionary plus some functions. Embrace functional programming. Rediscover the Strategy pattern and then all those things from imperative code you tried so hard to forget after Haskell. Find a balance.

使用Python尝试http://challenge.greplin.com/