Reference manual for python? [closed]

旧城冷巷雨未停 提交于 2019-12-11 06:59:16

问题


Is there a recommended reference manual for python that's better than the official docs? I'm an experienced programmer (PHP, C#, javascript, and some C most recently), and I find the python manual pretty lacking compared the PHP manual and MSDN. In particular, the official docs never seem to tell me what errors can happen if I pass in something invalid, and there's apparently not a way to navigate within a module.

Take the os module for example. There's no list of constants or methods I can call on that page, so I have to Ctrl+f for "stat(" until I find it. Then, once I do find it, it doesn't tell me what to expect if I call stat with a directory that doesn't exist, so I just have to try it in a terminal and see what happens.

This seems wildly inefficient… how do python programmers deal with this?


回答1:


In practice, you either make a quick test program to check the behavior, or read the source code. Much of the Python standard library code is fairly clearly written and in fact rather self-documenting, so it's standard practice to refer to it when you need to know the nitty-gritty details of how something works.

One exception: with low-level system functions such as many of those in the os module, the functions map directly on to their C namesakes for the underlying platform. So if you need to know about the behavior of Python's stat, you look up the reference documentation for your platform's native C stat call. In these cases the Python library docs often only explain the basic purpose of the function and how it differs from its C equivalent, if at all.




回答2:


I don't think I ever had the same feeling towards the python docs as you do but I did some times need to go out of my way some times for a better understand of how a part of python works. Though that is how most language are. Python is a quick and easy language to learn which requires less time on docs and more time programming. Also python's user base isn't as large as PHP. PHP has people constantly giving examples and details on certain functions daily.

Another great thing about python is its interactive shell to test things out. Just my idea of programming you learn more by doing then seeing. So if you're ever interested in testing something you don't need to drag through compiling, just write a quick script in the interpreter. the interpreter also has reference tools. Example dir(<identifier>) and help(<identifier>) for module, clasa or function needs.

Any way enough defending my favorite language, pyDoc is a little useful tool to help you get what you need from python.

pydoc is a tool that comes with Python that can be used for viewing and generating Python documentation.



来源:https://stackoverflow.com/questions/8147704/reference-manual-for-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!