mutable member, bug or ...
Sambo
sambo at void.com
Sun Jun 4 12:05:03 EDT 2006
By accident I assigned int to a class member 'count' which was initialized to (empty) string and had no error till I tried to use it as string, obviously. Why was there no error on assignment( near the end ).
class Cgroup_info:
group_name = ""
count = "0" #last time checked and processed/retrieved
first = "0"
last = ""
retrieval_type = "" # allways , ask( if more than some limit), none
date_checked = ""
time_checked = ""
new_count = ""
new_first = ""
new_last = ""
# local storage maintanance vars
pointer_file = ""
message_file = ""
#maintanance vars
cur_mess_num = 0
cur_mess_id = ""
def __init__( self ):
group_name = ""
count = "0" #last time checked and processed/retrieved
def get_count( self ):
print self.count, type( self.count )
return string.atoi( self.count, 10 )
class server_info:
def "(server_info::)"get_group_stat( self, grp ):
gr_info = Cgroup_info()
gr_info.group_name = grp
try:
ind = self.group_list.index( grp )
except ValueError:
gr_info.count(0)
return ( gr_info )
print ind
if len( self.group_list[ind].split() ) == 4:
gr_info.count = self.group_list[ind].split()[1]
gr_info.first = self.group_list[ind].split()[2]
gr_info.last = self.group_list[ind].split()[3]
else:
gr_info.count = gr_info.first = gr_info.last = "0"
return( gr_info )
More information about the Python-list
mailing list