Note that there are some explanatory texts on larger screens.

plurals
  1. POQuestions on "Python Is Not Java"
    primarykey
    data
    text
    <p>I'm a novice programmer with basic Java experience, and currently learning Python. I've stumbled across this blog post in another question thread:</p> <p><a href="http://dirtsimple.org/2004/12/python-is-not-java.html" rel="noreferrer">http://dirtsimple.org/2004/12/python-is-not-java.html</a></p> <p>and I've got a couple of questions regarding the topic posted:</p> <hr> <blockquote> <p>1) "Oh, and all those Foo.Bar.Baz attribute chains don't come for free, ... , so each dot counts. "</p> </blockquote> <p>Is the solution to this particular problem is importing module and its method beforehand? Such as:</p> <pre><code> from Foo.Bar import Baz ... #now Baz() can be called directly without using Foo.Bar.Baz() everytime </code></pre> <hr> <blockquote> <p>2) Got a switch statement? The Python translation is a hash table, not a bunch of if-then statments.</p> </blockquote> <p>There are several related answers regarding this topic, but they also raise a couple of questions:</p> <ol> <li>Use of if-else is cleaner, but it doesn't have the advantage of constant time O(1) in switch statement.</li> <li>Use of hash for constant time O(1)</li> <li>Use of lambda function in hash for comparison (not recommended) <ul> <li>Why is it not recommended? Is it because the lambda function removes the constant factor of hash?</li> </ul></li> <li>Use of bisect module <ul> <li>Does this method retain the constant time O(1), or it is just another type of lambda function?</li> <li>So what method in Python, that is equal to switch statement, with constant time O(1), while at the same time allowing comparison statement?</li> </ul></li> </ol> <hr> <blockquote> <p>3) Getters and setters are evil. Evil, evil...don't write getters and setters ... This is what the 'property' built-in is for ... In Python, this (getter and setter) is silly, because you can start with a normal attribute and change your mind at any time, without affecting any clients of the class.</p> </blockquote> <p>I don't really quite understand this part. </p> <p>Also, it seems that in Python public and private method or variable can be easily accessed, in contrast of that in C++ and Java. Is there any design reason for this behavior?</p> <hr> <p>Finally, is there any recommended further good read on Python vs. any other programming language?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload