I am a beginner programmer with basic Java experience and am currently learning Python. I came across this post in another question:
http://dirtsimple.org/2004/12/python-is-not-java.html
and I have a few questions regarding a published topic:
1) "Oh, and all these Foo.Bar.Baz attribute chains donβt come for free, ... so every point is counted."
Is the solution to this problem a problem of importing the module and its method in advance? For instance:
from Foo.Bar import Baz ... #now Baz() can be called directly without using Foo.Bar.Baz() everytime
2) Got a switch statement? The Python translation is a hash table, not an if-then statments relationship.
There are several related answers on this topic, but they also raise a couple of questions:
- Using if-else is cleaner, but it does not have the benefit of O (1) constant time in the switch statement.
- Using a hash for constant time O (1)
- Using a lambda function in a hash for comparison (not recommended)
- Why is this not recommended? Is it because the lambda function removes a constant hash coefficient?
- Using the bisect module
- Does this method keep O (1) constant time, or is it another type of lambda function?
- So, which method in Python is equal to the switch statement, with constant time O (1), and at the same time allowing the comparison operator?
3) Getters and setters are evil. Evil, evil ... do not write getters and setters ... This is what is built into the "property" ... In Python, this (getter and setter) is stupid, because you can start with a regular attribute and change your mind to any time without affecting class customers.
I do not quite understand this part.
In addition, it seems that in a public and private method or Python variable, you can easily access it, as opposed to open in C ++ and Java. Are there any constructive reasons for this behavior?
Finally, are there any recommendations for further good reading in Python compared to any other programming language?