Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Python is almost perfect.

Name: Anonymous 2011-10-02 18:32

At least it is closer to perfection than any other language.

If Python "forces" you to indent anywhere you wouldn't have indented anyway, you should probably just stop programming. By assuming the competency of programmer, Python effectively eliminates the need for braces and semi-colons. Too incompetent to understand? Have fun with Ruby.

Value syntactic simplicity from the interpreter's point of view over syntactic beauty and elegance from the programmer's point of view? Have fun with Lisp. Since my complex human brain is capable of quickly understanding more than two special characters in addition to a base-10 numerical system and 26-letter alphabet, Python does not confuse me. If you're more comfortable with globs of unstructured text surrounded by thousands of parentheses, then enjoy your toy language. That's why Python has been around a fraction of the time Lisp has, yet it has exponentially more practical application than Lisp does.

Python is for grown up programmers. Perl is for old men who didn't have Python in their time. Everything else is for children who want to put on big kids clothes and play grown up.

Name: Anonymous 2011-10-03 0:23

>>30
Why does it matter what Guido prefers? filter, map and friends are still there if you want them. I prefer the Python approach anyway because it produces a generator (which the square brackets convert to a list). I typically prefer the Pythonic way. Consider:


class Vector(tuple):
 
  def __add__(self, other):
    if isinstance(other, Vector) and self.dim() == other.dim():
      # python way
      return Vector(x + y for x, y in zip(self, other))
      # lambda way
      return Vector(map(lambda x, y: x + y, self, other))
    else:
      raise ValueError

  def __mul__(self, other):
    if isinstance(other, Vector):
      return self.dot(other)
    else:
      return self.scale(other)

    def scale(self, other):
      # python way
      return Vector(x * other for x in self)
      # lambda way
      return Vector(map(lambda x: x * other, self))

    def dot(self, other):
      if isinstance(other, Vector) and self.dim() == other.dim():
        # python way
        return sum(x * y for x, y in zip(self, other))
        # lambda way
        return sum(map(lambda x, y: x * y, self, other))
      else:
        raise ValueError

    def dim(self):
      return len(self)


The generators are easier to understand, IMO, and almost always faster. You can write generators in Lisp, but not nearly as elegantly as you can in Python.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List