Java -> Python?

前端 未结 5 833
深忆病人
深忆病人 2021-01-30 02:51

Besides the dynamic nature of Python (and the syntax), what are some of the major features of the Python language that Java doesn\'t have, and vice versa?

5条回答
  •  佛祖请我去吃肉
    2021-01-30 03:15

    Apart from what Eli Courtwright said:

    • I find iterators in Python more concise. You can use for i in something, and it works with pretty much everything. Yeah, Java has gotten better since 1.5, but for example you can iterate through a string in python with this same construct.
    • Introspection: In python you can get at runtime information about an object or a module about its symbols, methods, or even its docstrings. You can also instantiate them dynamically. Java has some of this, but usually in Java it takes half a page of code to get an instance of a class, whereas in Python it is about 3 lines. And as far as I know the docstrings thing is not available in Java

提交回复
热议问题