python参考手册? [英] Reference manual for python?

查看:179
本文介绍了python参考手册?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

python推荐的参考手册比官方文档好吗?我是一个有经验的程序员(PHP,C#,javascript和一些C最近),我发现python手册相当缺乏比较PHP手册和MSDN。特别是,官方文档似乎并没有告诉我如果我传递一些无效的错误,可能会发生什么错误,而且显然没有办法在模块中导航。



例如 os模块。没有可以在该页面上调用的常量或方法列表,所以我必须Ctrl + f为 stat(直到找到它,然后,一旦找到它不告诉我如果我调用 stat 与一个不存在的目录,所以我只需要尝试在一个终端,看看什么发生。



这似乎非常低效... python程序员如何处理这个?

解决方案

在实践中,您可以制作一个快速测试程序来检查行为,或者阅读源代码。许多Python标准库代码相当清楚地写出来,实际上相当自我记录,所以标准做法是当您需要了解有关某些工作的细节时,请参考它。



一个例外:具有低级系统功能,如许多 os 模块,功能直接映射到底层平台的C名称,所以如果你需要知道关于Python的 stat 的行为,您将查找平台的本机C stat 调用的参考文档。在这些情况下,Python库文档通常只会解释该函数的基本目的,以及它与C的等价物的区别。


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?

解决方案

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.

这篇关于python参考手册?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆