C# 为 .NET 开发人员学习 Python
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1072530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Learning Python for a .NET developer
提问by Abhijeet Patel
I have been doing active development in C# for several years now. I primarily build enterprise application and in house frameworks on the .NET stack.
几年来,我一直在用 C# 进行积极的开发。我主要在 .NET 堆栈上构建企业应用程序和内部框架。
I've never had the need to use any other mainstream high level languages besides C# for my tasks, since .NET is the standard platform we use.
除了 C# 之外,我从来不需要使用任何其他主流高级语言来完成我的任务,因为 .NET 是我们使用的标准平台。
There are some legacy Python applications that I have been asked to support going forward, I have no exposure to python and dynamic languages in general(although I've done a fair bit of JavaScript).
我被要求支持一些遗留的 Python 应用程序,我一般没有接触过 Python 和动态语言(尽管我已经做了相当多的 JavaScript)。
I was hoping to get some guidance/advise to aid in how to go about learning a language like python for the statically typed mind.
我希望得到一些指导/建议,以帮助如何为静态类型的思维学习 Python 之类的语言。
EDIT: Using IronPython is not an option!
编辑:使用 IronPython 不是一种选择!
采纳答案by Alex Martelli
Foord and Muirhead's IronPython in Actionis an amazingly good book, perfectly suitable for teaching Python to .NET folks as well as teaching .NET to Python folks. I may be biased, as I was a tech reviewer and Foord is a friend, but I've had other cases in the past where a friend wrote a book and I tech reviewed it -- and ended up deciding the book was just wrong and publicly saying so (way to lose friends, but, I just can't tell a lie, not where Python is concerned at least!-)
Foord 和 Muirhead 的IronPython in Action是一本非常好的书,非常适合向 .NET 人员教授 Python 以及向 Python 人员教授 .NET。我可能有偏见,因为我是一名技术评论员,而 Foord 是我的朋友,但过去我也遇到过其他情况,一位朋友写了一本书,我对它进行了技术——最终认为这本书是错误的,公开这样说(失去朋友的方式,但是,我不能说谎,至少在 Python 关注的地方!-)
Edit: If you're forbidden from moving to IronPython (which would probably support your legacy apps just fine, btw), there are better answers: Mark Pilgrim's Dive into Pythonis often considered the best Python intro for the experienced developer, and my own Python in a Nutshellhas been praised as the fastest way onboard for superstar developers. I amof course biased in favor of these -- Mark is a colleague, and my wife was a key tech editor for his book (and my own as well), and obviously I'm biased in favor of my own book too;-). But then, I dotend to be biased towards a lot of the best Python books, as I've either had a hand in their editing, or am friends with their authors, or both;-).
编辑:如果你被禁止迁移到 IronPython(顺便说一句,它可能会很好地支持你的遗留应用程序),有更好的答案:Mark Pilgrim 的Dive into Python通常被认为是有经验的开发人员最好的 Python 介绍,而我自己的Python in a Nutshell被誉为超级明星开发人员最快的入门方式。我是当然赞成这些偏见的-马克是同事,而我的妻子为他的书(和我自己也一样)的关键技术编辑,很明显,我赞成我自己的书太有偏见; - )。但是,我确实倾向于偏向于很多最好的 Python 书籍,因为我要么参与了他们的编辑工作,要么与他们的作者是朋友,或者两者兼而有之;-)。
回答by eric.christensen
I would recommend using IronPythonto help you learn. It is an implementation of Python on the .NET framework. So you can use/learn Python with access to the .NET class library.
我建议使用IronPython来帮助您学习。它是 Python 在 .NET 框架上的一个实现。因此,您可以通过访问 .NET 类库来使用/学习 Python。
A good place to start is by downloading IronPythonand looking at IronPython in Action, which is a very good book looking at Python on the .NET framework.
一个很好的起点是下载IronPython并查看IronPython in Action,这是一本关于 .NET 框架上的 Python 的非常好的书。
EDIT: Since IronPython is not an option, disregard this answer. Thanks though.
编辑:由于 IronPython 不是一个选项,请忽略此答案。不过谢谢。
回答by sunqiang
The book Pro IronPythonis worth reading too if you have time.
如果您有时间,Pro IronPython这本书也值得一读。
回答by Newtopian
Hardest thing I was confronted to in using python coming from Java was to properly wrap my head around the Duck Typing thing... At first I thought it was just plain horrible and just dressed the hairs on the back on my neck.
在使用来自 Java 的 python 时,我遇到的最困难的事情是正确地将我的头包裹在 Duck Typing 的东西上......起初我认为这简直太可怕了,只是把我脖子上的头发梳了起来。
Next is the scope by convention, but that one is pretty easy. And the importance of white spaces gave me a few bumps.
接下来是约定俗成的范围,但这很容易。白色空间的重要性给了我一些冲击。
However once you ease yourself in the language's concision and speed of development you learn to appreciate it a lot more. After a while I thought it was the best thing that ever happened to me !! :-)
然而,一旦你放松了语言的简洁性和发展速度,你就会学会更多地欣赏它。过了一会儿,我认为这是发生在我身上的最好的事情!!:-)
here are a few things that helped me a lot :
这里有一些对我帮助很大的事情:
First I started with this bookand got the basics of the language and for everyday use the Python Quick Reference Cardwas very helpful. Also the consolewill be your best ally to try quick things and solidify your learning.
首先,我从这本书开始,了解了该语言的基础知识,对于日常使用,Python 快速参考卡非常有帮助。此外,控制台将是您尝试快速操作和巩固学习的最佳盟友。
For IDEs, coming from the eclipse world PyDevwas a natural choice for me, but there were many more to choose from. But if you are more familiar to the Visual Studio environment the Python Tools for Visual Studiois pretty darn good too.
对于 IDE,来自 Eclipse 世界的PyDev对我来说是一个自然的选择,但还有更多可供选择。但是,如果您更熟悉 Visual Studio 环境,Visual Studio 的Python 工具也非常好。
Good luck, Hopefully you'll find Python as much fun as I did.
祝你好运,希望你会发现 Python 和我一样有趣。
回答by Lennart Regebro
There is a big initial hurdle of getting comfortable with dynamic typing. The first step is when you look at Python-code and realize that variables aren't defined anywhere, you just create them out of thin air, which feels like jumping over a cliff. There is a brief moment before your hang glider catches the air properly.
适应动态类型有一个很大的初始障碍。第一步是当您查看 Python 代码并意识到变量没有在任何地方定义时,您只是凭空创建它们,感觉就像跳过悬崖一样。在您的悬挂式滑翔机正确捕捉空气之前有一小段时间。
And then it's going to take time before you trust your newfound dynamic wings, and you probably only can get their by doing aerobatics with them. Learn how python handles references, have fun with monkey-patching methods, duck type various animals. Try to learn some ugly tricks.
然后你需要时间来信任你新发现的动态翅膀,你可能只能通过与它们进行特技飞行来获得它们。了解 python 如何处理引用,享受猴子修补方法的乐趣,鸭子类型的各种动物。尝试学习一些丑陋的技巧。
And although you can't use IronPython for this, there is no reason you can't use it to learn Python.
尽管您不能为此使用 IronPython,但您没有理由不能使用它来学习 Python。
回答by pupeno
I would recommend just to read a book about it. A book for beginners. It'll contain many stuff you already know but you won't miss anything regarding using a dynamic language. I can point you to Dive into Python, which seems to be very friendly, or The Python Tutorialwhich seems to be very to the point (that's how I learned).
我建议只阅读一本关于它的书。适合初学者的一本书。它将包含许多您已经知道的内容,但您不会错过有关使用动态语言的任何内容。我可以向您指出Dive into Python,这似乎非常友好,或者Python Tutorial似乎非常切中要害(这就是我学习的方式)。
回答by Per Erik Stendahl
You're going to experience quite a bit of culture-shock going from C# to the wild duck-typed outback of Python. Lack of types and intellisense can be pretty daunting. Good thing that you're experienced in JavaScript. Also know that indent-sensitive block rules of Python can be very confusing for the inexperience (usually you either love it or hate it :-)
从 C# 到 Python 的野鸭类型的内陆,您将体验到相当多的文化冲击。缺乏类型和智能感知可能非常令人生畏。你在 JavaScript 方面有经验是件好事。还要知道 Python 的缩进敏感块规则可能会因缺乏经验而非常混乱(通常你要么喜欢它,要么讨厌它:-)
Apart from that the biggest challenge moving from one language to another is usually the framework. Getting to know all the classes and functions Just Takes Time unfortunately.
除此之外,从一种语言迁移到另一种语言的最大挑战通常是框架。不幸的是,了解所有的类和函数需要时间。
回答by Stan Graves
For an experienced developer learning Python, Dive Into Pythonis a very good book.
对于学习 Python 的有经验的开发人员来说,Dive Into Python是一本非常好的书。
Wesley Chun's Core Python Programmingbook takes a more "ground up" approach, which may be a little slow for an experienced developer. But it allowed for very easy comparisons of the basic syntax and operators compared to other languages. Wesley's writing style is very easy to read, and his example projects are non-trivial enough to actually be interesting.
Wesley Chun 的Core Python Programming一书采用了更“接地气”的方法,这对于有经验的开发人员来说可能有点慢。但与其他语言相比,它允许非常容易地比较基本语法和运算符。Wesley 的写作风格非常容易阅读,他的示例项目非常重要,实际上很有趣。
The Python Cookbookis an excellent reference for learning to program in a 'Pythonic' way. This book contains hundreds (?) of examples of how to solve common everyday problems with Python. In general, the "Cookbook" series will expose you to the idioms of the language faster than any other book.
所述的Python食谱是用于在“Python化”的方式学习编程一个很好的参考。本书包含数百个 (?) 示例,说明如何使用 Python 解决常见的日常问题。一般来说,“Cookbook”系列将比任何其他书籍更快地让您了解该语言的习语。
Whenever I need to learn a new programming language, I start using it for all the 'daily maintenance' tasks that come up - all the little things that I would normally solve with a shell script or with common unix tools - I start to use the new language to solve those problems. Since you have .NET experience, IronPython is probably a good way to leverage that knowledge while learning Python. Even if you only install IronPython in a personal sandbox...and use it for all your daily busy work coding tasks - that can be a great way to learn the syntax and idioms of Python.
每当我需要学习一门新的编程语言时,我就会开始将它用于所有出现的“日常维护”任务——我通常会用 shell 脚本或常用的 unix 工具解决的所有小问题——我开始使用解决这些问题的新语言。由于您拥有 .NET 经验,因此 IronPython 可能是在学习 Python 时利用这些知识的好方法。即使您只将 IronPython 安装在个人沙箱中……并将其用于所有日常繁忙的工作编码任务 - 这也是学习 Python 语法和习语的好方法。