From: Ville Vainio Date: 2004-04-03T17:14:22+09:00 Subject: Re: deciding between ruby and python >>>>> "Atrdridel" == Aredridel writes: >> Calling to_s() seems kinda brutal from the Python POV. Perhaps this is Atrdridel> And it certainly is convenient: .... Atrdridel> Then with an array of Sockets, you can do: Atrdridel> [......].join("\n") Atrdridel> src: 10.10.0.0 dest: 10.10.0.1 Atrdridel> src: 10.10.0.0 dest: 10.10.0.2 Atrdridel> Useful? Indeed it is. We do the same thing in Python (just define __str__() in your classes), but with the added spice of "explicit is better than implicit". So you need to coerce thems to strings before you join them: list_as_strings = [str(e) for e in list_of_objects] I consider this a feature, because it leads to more robust code and less surprises. If I expected to have a list of strings, but one element is a socket, I should know about it. 'Explicit is better than implicit' comes from "Zen of Python", if someone didn't know. Those who didn't, check out: http://www.python.org/doc/Humor.html#zen Atrdridel> The tradition of duck-typing and various kinds of Atrdridel> hammer to coerce objects into acting like the Atrdridel> appropriate types is an appealing part of Ruby. The duck part applies to Python too (even though we usually speak of dynamic typing ;-). The implicit coercion is going to burn you on large projects ("Errors should never pass silently. Unless explicitly silenced."), though. Perhaps this is indicative of the more general Ruby tradition (taking influence of perl?) of optimizing shorter scripts at the cost of large scale development? -- Ville Vainio http://tinyurl.com/2prnb