{"id":110,"date":"2008-06-04T00:04:49","date_gmt":"2008-06-03T18:34:49","guid":{"rendered":"http:\/\/www.bin-co.com\/blog\/?p=110"},"modified":"2008-06-04T00:04:49","modified_gmt":"2008-06-03T18:34:49","slug":"python-reference-manual-has-a-lot-to-learn-from-php","status":"publish","type":"post","link":"https:\/\/www.bin-co.com\/blog\/2008\/06\/python-reference-manual-has-a-lot-to-learn-from-php\/","title":{"rendered":"Python Reference Manual has a lot to Learn From PHP"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.bin-co.com\/blog\/wp-content\/uploads\/2008\/03\/python-logo.gif\" alt=\"\" title=\"Python Logo\" width=\"211\" height=\"71\" class=\"alignnone wp-image-97 intro\" align=\"right\"  \/><\/p>\n<p class=\"intro\">Unlike the other scripting languages I work with(like PHP, Ruby, JavaScript, etc.), I am not comfortable using Python. I have made some stuff in Python(for example, <a href=\"http:\/\/lindesk.com\/2008\/04\/frees-hard-disk-drives-free-space-viewer\/\">frees<\/a>) &#8211; but I could get into the flow as easily as with other languages. For the longest time, I thought it was because of the whitespace issue. But recently, I created a small Python script &#8211; that&#8217;s when I understood that whitespace does not concern me. <strong class=\"highlight\">What make me angry at python is its documentation\/manual<\/strong>.<\/p>\n<p>By Python Manual, I mean the official Python Manual available at <a href=\"http:\/\/docs.python.org\/\">http:\/\/docs.python.org\/<\/a>. I have <strong class=\"highlight\">downloaded the entire <a href=\"http:\/\/www.python.org\/doc\/2.5.2\/download\/\">manual to my system as HTML files<\/a> and use that as a reference<\/strong> when working with Python. This is what I have done for all the other languages I work with&#8230;<\/p>\n<ul>\n<li><a href=\"http:\/\/perldoc.perl.org\/\">Perl<\/a><\/li>\n<li><a href=\"http:\/\/www.php.net\/manual\/en\/\">PHP<\/a><\/li>\n<li><a href=\"http:\/\/www.ruby-doc.org\/docs\/ProgrammingRuby\/\">Ruby<\/a><\/li>\n<li><a href=\"http:\/\/docs.sun.com\/source\/816-6408-10\/\">JavaScript<\/a> <\/li>\n<li><a href=\"http:\/\/www.w3.org\/TR\/REC-CSS2\/\">CSS<\/a><\/li>\n<li>etc.<\/li>\n<\/ul>\n<h2>Finding a Function<\/h2>\n<p>There is one big problem with using HTML files as your reference &#8211; you cannot search through it. So I try to find a page in the documentation that <strong class=\"highlight\">lists all the functions in a single page<\/strong>. When I need to find a function, all I have to do is <strong class=\"highlight\">search through this page<\/strong>. These pages in the documentation serves this purpose&#8230;<\/p>\n<ul>\n<li><a href=\"http:\/\/www.php.net\/manual\/en\/indexes.php\">PHP<\/a><\/li>\n<li><a href=\"http:\/\/perldoc.perl.org\/index-functions.html\">Perl<\/a><\/li>\n<li><a href=\"http:\/\/docs.sun.com\/source\/816-6408-10\/bklast.htm\">JavaScript<\/a><\/li>\n<li><a href=\"http:\/\/www.ruby-doc.org\/docs\/ProgrammingRuby\/html\/builtins.html\">Ruby<\/a><\/li>\n<\/ul>\n<p>What about Python? Well, <strong class=\"highlight\">Python don&#8217;t have such a page<\/strong> in their manual. The nearest one I could find a combination of four pages &#8211; <a href=\"http:\/\/docs.python.org\/modindex.html\">Module Index<\/a> + <a href=\"http:\/\/docs.python.org\/lib\/genindex.html\">Library Index<\/a> + <a href=\"http:\/\/docs.python.org\/tut\/node19.html\">Tutorial Index<\/a> + <a href=\"http:\/\/docs.python.org\/ref\/genindex.html\">Language Index<\/a>. Its no where near as useful.<\/p>\n<p>Even if you are online(remember, many people are not connected all the time), its still <strong class=\"highlight\">not easy to find a function in Python documentation &#8211; even with searching<\/strong> capabilities. Don&#8217;t believe me? OK &#8211; go to <a href=\"http:\/\/docs.python.org\/\">Python Docs<\/a> and try to find the documentation for the function that, say, reverses an array. Now go to the <a href=\"http:\/\/php.net\/manual\/en\/\">PHP site<\/a> and do the same.<\/p>\n<h2>Reference Formats<\/h2>\n<p>Anyway, I cannot really complain about the the availability of the &#8216;function page&#8217;. Its just the way I prefer &#8211; other people may not want such a page. But I can complain about the fact that <strong class=\"highlight\">they don&#8217;t provide a CHM file<\/strong> in their <a href=\"http:\/\/www.python.org\/doc\/2.5.2\/download\/\">downloads section<\/a>. CHM solves the problem as you can search through them easily.<\/p>\n<p>PHP, on other hand, <a href=\"http:\/\/www.php.net\/download-docs.php\">provides the CHM file<\/a>. This makes the PHP manual much more easier to use.<\/p>\n<p>Even though Python don&#8217;t officially provide a CHM file, others have made it available on the net. Its just a <a href=\"http:\/\/www.google.com\/q=python+reference+chm\">google search away<\/a>. But I prefer to get these stuff from an official source.<\/p>\n<h2>Level of Detail in the Documentation<\/h2>\n<p>The worst sin of the Python manual is that the <strong class=\"highlight\">documentation is not detailed enough<\/strong>. To better understand this, let&#8217;s take an example &#8211; say the array reversal function. First we take a look at the Python <a href=\"http:\/\/docs.python.org\/lib\/module-array.html#l2h-779\">documentation for this function<\/a>&#8230;<\/p>\n<dl>\n<dt>reverse()<\/dt>\n<dd>Reverse the order of the items in the array.<\/dd>\n<\/dl>\n<p>One line. That&#8217;s it! If you are not well versed in Python, you will have no idea of how to use this function &#8211; because there is no example. Most people will expect that the array must be given as the argument. But the argument list is empty in the documentation. That&#8217;s because the array is not passed as an argument &#8211; rather, in Python, this function is a member function of the array object &#8211; so the proper usage will be something like this&#8230;<\/p>\n<pre><code class=\"python\">x = [1,2,4]\nx.reverse()\n#Now x has the value [4,2,1]<\/code><\/pre>\n<p>I know that because I know Python &#8211; but if a new user manages to find the documentation for this function, he will be confused. Another thing &#8211; I am not saying that there are no examples in the documentation &#8211; examples are given for a lot of functions. But its no where near the level that PHP has achieved.<\/p>\n<p>OK &#8211; now lets see the PHP manual for the same function &#8211; <a href=\"http:\/\/php.net\/manual\/en\/function.array-reverse.php\">array_reverse()<\/a>. There is an entire page for that function. Not just for this function &#8211; there is <strong class=\"highlight\">one page of documentation for every function<\/strong> in PHP. And <strong class=\"highlight\">there are examples<\/strong>. And at the end, <strong class=\"highlight\">there is a collection of &#8216;user notes&#8217;<\/strong> &#8211; making each function much clearer. Beautiful!<\/p>\n<p>I feel a bit guilty about comparing Python with PHP documentation &#8211; <strong class=\"highlight\">PHP has the best documentation in its class<\/strong> of languages. But still, Python has a lot to learn from PHP(I wanted to say that for a long time \ud83d\ude09 ).<\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Unlike the other scripting languages I work with(like PHP, Ruby, JavaScript, etc.), I am not comfortable using Python. I have made some stuff in Python(for <a class=\"mh-excerpt-more\" href=\"https:\/\/www.bin-co.com\/blog\/2008\/06\/python-reference-manual-has-a-lot-to-learn-from-php\/\" title=\"Python Reference Manual has a lot to Learn From PHP\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,21,30],"tags":[95,177,210,225,232],"class_list":["post-110","post","type-post","status-publish","format-standard","hentry","category-opinion","category-php","category-web-development","tag-documentation","tag-manual","tag-php","tag-python","tag-reference"],"_links":{"self":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/comments?post=110"}],"version-history":[{"count":0,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/posts\/110\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/media?parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/categories?post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bin-co.com\/blog\/wp-json\/wp\/v2\/tags?post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}