[FRPythoneers] Object instantiation (newbie question)

DeVerter at robinsonmechanical.com DeVerter at robinsonmechanical.com
Thu Aug 2 11:23:40 MDT 2001


My 'Thanks!' to everyone for your suggestions.  After a few changes this
morning to incorporate a little of everyone's ideas I am now plowing ahead
and writing the actually flow of the game.

Mark d.




                                                                                                                                        
                    Ken Kinder <kkinder at tridog.com>                                                                                     
                    Sent by:                                  To:     frpythoneers at lists.community.tummy.com                            
                    frpythoneers-admin at lists.community        cc:                                                                       
                    .tummy.com                                Subject:     Re: [FRPythoneers] Object instantiation (newbie question)    
                                                                                                                                        
                                                                                                                                        
                    08/01/01 07:23 PM                                                                                                   
                    Please respond to frpythoneers                                                                                      
                                                                                                                                        
                                                                                                                                        




Yes, since you are accessing elements in a dictionary through a sequence
of numbers anyway, a list would make more sense.

Sean Reifschneider wrote:
>
> 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))
>
> or:
>
>    player_list = []
>    for player in range(num_players):
>       player_list.append(Hand(get_name()))
>
> 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
>
> Sean
> --
>  "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
> _______________________________________________
> This message sent by the FRPythoneers mailing list.
> Unsubscribe: echo unsubscribe |
FRPythoneers-request at lists.community.tummy.com
> URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers
_______________________________________________
This message sent by the FRPythoneers mailing list.
Unsubscribe: echo unsubscribe |
FRPythoneers-request at lists.community.tummy.com
URL: http://lists.community.tummy.com/mailman/listinfo/frpythoneers







More information about the FRPythoneers mailing list