Day 1
- So there is
pyenv
. It seems to be the same asrbenv
. Noone seems to be using it. - There is nothing like
bundler
. I'm going withpip install -r requirements.txt
. This is like a mixture of aGemfile
and aGemfile.lock
but the actual libraries seem to be is stored globally. I am disappointed. - Testing. The standard choice here seems to be either
pytest
or the built in unit test. Neither of them seems to be BDD. Since Python does not have Ruby's blocks for writing DSLs everything looks really ugly compared to RSpec.
Day 2
- Ruby:
array.length
vs Pythonlen(list)
. Why do I have to call a globally defined function? Because the OO is done well? - In Ruby I can use inject with a block. Again, there are some functions in Python for
filter
,map
andreduce
. Thereduce
function was moved out of the standard library and into thefunctools
library. Here is an example inject Ruby vs Python:
array.inject(0) { |result, element| result * element }
import functools
lam = lambda result, element: result * element
functools.reduce(lam, list)
- The standard pylinter complains about naming a variable "list" because that is
Redefining built-in 'list'
. Having a varialbe called list results in trouble when debugging with pdb because you cannot calllist
. - The default linter settings require comments.
- The linter enforces documentation. It seems Python emphasises documentation, Ruby readability of the code.
- The linter prefers locally defined methods over lambdas by default
- Class methdos: they come in two kinds
@classmethod
and@staticmethod
. In any case, the syntax looks like a hack. - Python made a design choice to have all methods public. To compensate for this, there is a convention of using leading uderscores for methods which should not be called from outside the class. This results ugly methods everywhere.
- "private" memeber methods have to be called using
self.
explicitely. Again, this is the opposite of the Ruby design. - Spacing: why 4?
Day 3
- Nice: list slicing support in syntax. Maybe a bit too powerful (steps).
- mixed blessing: list comprehensions and generators (lambdas still look more natural to me)