And yes, installing scipy from scratch is a bear. If you're using a modern linux distribution, you probably want to install a python scipy package.
And yes, installing scipy from scratch is a bear. If you're using a modern linux distribution, you probably want to install a python scipy package.
And that's another difference between the two communities: Gems are always installed through Rubygems, no exceptions. Distribution's packaging systems (I'm looking at you, Debian) have always just screwed things up, and so Rubyists tend to just remove any system Ruby, install rvm from source (which entails running one bash script), and doing it all through there. Then, everything works great.
"There should be one-- and preferably only one --obvious way to do it."
The "obvious" portion of that makes it a little less strict than your quotation. I think it is a "good" axiom to try and aim for. The problem is people think differently and you can't force that really.
I like Perl, where almost anything goes, though. :)
The "obvious" portion of that makes it a little less
strict than your quotation.
The "obvious" portion is what makes it such a problem. If you have one library for a task, then the choice really is obvious. If you have two libraries, each very good but offering different takes on servicing a task, then "obvious" becomes a problem, and if "obvious" is a goal then one of those libraries becomes a problem."Obvious" is a problematic goal much like "fair" and "equal" are problematic goals in society. You end up sacrificing much that is good and valuable in pursuit of what is often a vague and situational ideal.
The subjectivity of the obviousness being nicely handled by the next stanza:
> Although that way may not be obvious at first unless you're Dutch.
I do think, though, that Python's list comprehensions are quite beautiful, and I'm looking forward to using them.
i.e you write 4+2 to add things not 4.add(2)
>>> class Foo:
... def __init__(self, name):
... self.name=name
>>> a1 = Foo('Alice')
>>> a2 = Foo('Alice')
>>> a1==a2
False
>>> Foo.__eq__ = lambda self,other: self.name==other.name
>>> a1==a2
TrueThe explicit self for methods comes straight out of the Python "rule" that explicit is better than implicit. Python is purposefully putting explicitness ahead of beauty, and I agree it's not particularly beautiful. Something that I find even less beautiful in Python is its super syntax:
super(theClass, self).method()
I'm still relatively new to Python, but I would argue that the super syntax goes a bit too far in explicitness (and I think it's fair to argue the same thing for the "self" in methods). Incidentally, there is a PEP (Python Enhancement Proposal) from 2007 to make super just work as super().method().
Python then actually ends up taking advantage of this by having len able to use any of several interfaces. It may call double-underscore-len, but it may also traverse an iterator. It could potentially do other things as well. It's actually a straightforward application of the "prefer interfaces over inheritance" to the dynamic language case. You can criticize the spelling of the double-underscore methods (which if you are really grumpy, can actually be fixed by a metaclass, though I think the cost/benefit tradeoff is bad unless you are the only person who will ever use that code), but if you haven't used them you may not realize just how finely tuned they are, and how well they work with the functions that actually search over the interfaces to find the best one to use in a way somewhat difficult to replicate directly with a "method".
Python's arguably not merely "OK" but more right than
Ruby here, if you are really going to be an OO purist
(of certain flavors).
Ruby's flavor is primarily that of sending messages to receivers (hence parens being optional). Python seems more about invoking methods on objects.Lately I've heard a lot of chatter about Ruby Interfaces. They could be useful to achieve better unity. Though the Ruby collection API is already pretty consistent.
* You can nest classes and methods. This is ugly, so I never use it except in testsuites where declaring a mock class right in the test method is the best way to do it, but it's great to have "self" be the testcase and "xself" be the mocked method.
* There's no such thing as a magic variable. Every name you can reach is declared somewhere, either locally, globally, or from `__builtins__`. If self were automatic, then it would be invisible like the builtins, but it would change depending on where you used it from. The consistency is worth the minor inconvenience, IMHO.
unlike 'self' in other languages as a keyword, 'self' is just a variable with the same scoping.
i.e self always refers to the most inner scope in other languages (a special variable), meanwhile self in python is wherever self was bound in the current scope.
and fwiw: len is a holdover from earlier python (you can define a method __len__ if you want...)
No. len is basically a multimethod.
> (you can define a method __len__ if you want…)
You have to, it's part of the length protocol, `len()` will not work if you don't. Because `len(o)` calls `o.__len__()`). If you start calling underscore-methods directly (outside of a super() access), you're heading for trouble with your coworkers.
each(list) vs list.each
def(self, args)
__ugh__
can't do templates (erb?)
dislike object model (objects != functions etc)