When I talk about programming with Pythonista at work, I'm all taken to the flow of Ruby Diss.
Why do you hate it so much?
TMTOWTDI is an acronym for "There's More Than One Way To Do It." And is Perl's motto, which means "there is more than one way."
In Ruby, I don't know if it's because it inherits that idea, but many methods of built-in classes have aliases defined.
For example Enumerable#map,find,inject,select,include? Array#count Object#to_enum It is a place like that.
According to Pythonista, this creates nothing but confusion and learning costs.
Yup ** Maybe you're right ... **
I agree with the variety of solutions,
python
### a-Generate a random 8-character string consisting of z
# 1
str = ""
alphabet = ('a'..'z').to_a
8.times do
str << alphabet.delete(alphabet.sample)
end
# 2
('a'..'z').to_a.shuffle.take(8).join
# 3
('a'..'z').sort_by{rand}[0..7].join
Providing an alias for a method with the same function feels like a way to increase the wrong choices.
It doesn't say "Is it possible to get the size even with Array # length?" I sometimes wonder, "Why is there no fold because Enumerable has inject and reduce?"
You need to call it when you run Proc. Therefore, it seems that it is not possible to handle the function transparently as a first class object.
If Proc's calling syntax is aligned with the method, the simplicity of calling the method without () is lost.
python
constant = proc{42}
constant #=>Is constant a call or a reference to Proc?
Proc requires (), and special treatment such as is delicate, so I think this is fine.
According to Pythonista, I don't like the fact that the name is expanded to the top level when I require it in Ruby.
In Python, the filename becomes a module when imported and the global namespace is not polluted. You can also use from to specify a name to load to the top level.
There is no noise about this.
Well, I think I was saying something else ...
Recommended Posts