You wrote:

(...)

> i'm porting my palm pilot game to both python and ruby.
>
> i need to define 26 objects (coincidentally named a to z :)
>
> in python i can do this:
>
>
> #!/usr/bin/python
>
> import string, gebplanet
>
> for letter in string.lowercase:
>     exec '%s=gebplanet.planet()' % letter
>     exec '%s.name(letter)' % letter

A Python similar solution would looks like:

  #!/bin/env ruby

  require "gebplanet"

  for letter in 'a' .. 'z'
    eval "%s = Planet.new" % letter
    eval "%s.name('%s')" % [letter, letter]
  end

But I would use the #{} construct in strings ...

  for letter in 'a' .. 'z'
    eval "%{letter} = Planet.new"
    eval "%{letter}.name('%{letter}')"
  end

Still very close to Python, isn't it? :-)

(...)


HTH,
\cle