----- Original Message -----
> From: "C Smith" <[email protected]>
> I read that with 2.7 that I had to initialize class variables to
> immutable types. I think because I was working with the lists before
> they had been altered and were still empty lists. I will mess around
> tomorrow with the classes you suggested as I have yet to make use of
> decorators. Thanks.
The problem you referring too is probably the default value in *function
definition*.
Never write
class Foo(object):
def __init__(self, bar=[]):
self.bar = bar
The empty list is evaluated at the function definition and will be shared by
all instances of the class.
What you can do is
class Foo(object):
def __init__(self, bar=None): # None is immutable
self.bar = bar or []
On a completely unrelated topic:
I think you are using too much of default values for you arguments.
I tend to use them only for keeping something backward compatible.
Otherwise, use positional arguments, remember that explicit is better than
implicit.
Rememer your Table class:
class Table(object):
def __init__(self,bigblind=20,PLAYERNUM=0,pot=0,PLAYERORDER=None,
hand_done=0,
left_to_act=None,cost_to_play=0,in_hand=None,last_raise=0,cards_in_play=None,round='preflop'):
You do not need to to pass all attribute initializers to your init method. For
instance PLAYERNUM, which should be lowercase by the way, is clearly not
intended to be set at the Table creation, it is something changed when filling
seats.
Actually, since you've created your table this way:
table1=Table(bingblind=1)
It probably means that your table __init__ method should look like:
def __init__(self, bigblind):
self.bigblind= bigblind
self.hand_one = False
self.left_to_act = []
# etc...
By the way, avoid using directly 1 and 0 for coding booleans, use True and
False (see hand_one attribute).
JM
-- IMPORTANT NOTICE:
The contents of this email and any attachments are confidential and may also be
privileged. If you are not the intended recipient, please notify the sender
immediately and do not disclose the contents to any other person, use it for
any purpose, or store or copy the information in any medium. Thank you.
--
https://mail.python.org/mailman/listinfo/python-list