当你不必使用子类时。例如,您可能有一个 Java方法,该方法将java.io.OutputStream类型的参数转换为它写入的。你可以把它翻译成一个Python方法,你要小心只传递文件对象子类的实例。 但事实上没有必要这样做:你可以自由传递任何具有适当成员的 对象。 我想这是更一般规则的一个实例:当使用OO时,使用OO /> 你不需要。Using subclassing when you don''t have to. For instance, you might have aJava method which takes an argument of type java.io.OutputStream towhich it writes. You might translate this to a Python method to whichyou are careful to only pass instances of subclasses of file objects.But in fact there is no necessity for this: you are free to pass anyobject which has appropriate members.I suppose this is an instance of the more general rule: "using OO whenyou don''t have to". 我认为它们不存在。这样的书籍更倾向于在企业环境中进行开发,每个提案都必须通过多层管理来实现,而且什么都没有做到 个人独自工作,总是由团队工作在单独的部分工作 的项目。而且最终用户并没有真正得到更多的说法。 如何应该工作。它只是在如此高昂的开销,自上而下,覆盖你的屁股环境中,这些书被视为 完全有用。可能是因为没有人会被解雇 购买它们。 我会说像Python和Perl这样的语言是 这种发展文化。I don''t think they exist. Such books are targeted more towardsdevelopment in a corporate environment, where every proposal has to gothrough multiple layers of management, and nothing is ever done byindividuals working alone, always by "teams" working on separate partsof the project. And also where the end-users don''t really get much sayin how things are supposed to work. It''s only in such a high-overhead,top-down, cover-your-ass environment that such books are looked on asbeing at all useful. Possibly on the grounds that nobody ever got firedfor buying them.I''d say languages like Python and Perl are the absolute antithesis ofthis sort of development culture. 前段时间我不得不学习一点Java是为了能够编写一些签名的jython浏览器小程序,我可以在 高度限制的公共图书馆计算机上工作时使用它。所以我想我来自 相反的方向:-)无论如何我想知道为什么(以及如何!)非常小 jython脚本可以取代大块的java代码。 也许从jython的角度来看它会对你来说很有教育意义。我认为通过jython遍历 其类系统来实现自动生成或填充多少java代码将会很有趣。 br /> 我也希望它能为高级java创造一个机会,让你能够在jython中编写一些很酷的签名java applet。 > 用于python的idle.py的外观和感觉但是这将从 webbrowser运行。 我知道它可以完成,因为我确实写了一些实验但仍然很好的功能,比如一个jython控制台webbrowser小程序, a websucker.py在浏览器中运行,我攻击了其他一些 jython编辑器 - 控制台(eclipse很适合这类事情)添加一些 功能并自己做签名和库选择。 但是,不要问我的代码,它已经远远不够了。无论如何, 从那时起我找到了一份工作,让我可以获得更少锁定的电脑,这也很有趣。 安东Some time ago I had to learn a bit of Java in order to be able to writesome signed jython browser applets that I could use while working at ahighly restricted public library computer. So I guess I was coming fromthe opposite direction :-) Anyway I wondered why (and how!) very smalljython scripts could replace large blocks of java code.Maybe looking at it from a jython perspective will be educational foryou. I think it would be a lot of fun realizing how much java code canactually be ''automatically'' generated or filled in by jython traversingits class system.Also I''m hoping it would produce an opportunity for an advanced javacoder to write some cool signed java applet in jython that would havethe look and feel of idle.py for python but that would run from awebbrowser.I know it can be done because I did write some experimental but stillalready very functional things like a jython console webbrowser applet,a websucker.py running from within a browser, and I hacked some otherjython editor-console (eclipse is good for such things) to add somefunctionality and do my own signing and library selection.Don''t ask for my code yet though, it''s nowhere near presentable. Anyway,since then I found a job that gives me access to less locked downcomputers which is also fun.Anton 这篇关于寻找资源,使从Java到Python的跳转更容易,更高效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
09-03 09:19