[FRPythoneers] Object instantiation (newbie question)

Sean Reifschneider jafo at tummy.com
Wed Aug 1 17:59:15 MDT 2001

You don't want to make the objects "in the clear".  Remember, that even if
you were to do this, you'd be effectively instantiating them in a
dictionary anyway, because the symbols that are stored "in the clear" are
stored as part of a name-space dictionary by the Python interpreter.

Also, a dictionary may not be the best way to do it, but you certainly
could go that way.  Using an integer key for a dictionary is a bit odd
though.  Here are some alternatives:

   for player in range(num_players):
      name = get_name()
      player_dict[name] = Hand(player_dict(name))


   player_list = []
   for player in range(num_players):

Using a list is probably better for using integer-keyed items, because you
can implement a turn as:

   for player in player_list:
      print 'Your turn,', player.name

 "If life was fair, Elvis would be alive and all the impersonators would
 be dead."  -- Johnny Carson
Sean Reifschneider, Inimitably Superfluous <jafo at tummy.com>
tummy.com - Linux Consulting since 1995. Qmail, KRUD, Firewalls, Python

More information about the FRPythoneers mailing list