> > I suspect that you are misinterpreting this paragraph... > > *Important warning:* The default value is evaluated only once. This > makes a difference when the default is a mutable object such as a list, > dictionary, or instances of most classes. For example, the following > function accumulates the arguments passed to it on subsequent calls:
Yes, I think I am. > The argument packet_counter will get set to 0 everytime the function > gets call. If 0 happened to be an expression like [] (new list), then > packet_counter would get set to that list object every funtion call. That is my conclusion, but it's confusing because the web page example (with a new list) shows that the list is effectively preserved. > You may want a global variable? > def handle_packet.... > global packet_counter = 0 > ... Yes, I can do that. I have to get used the the "Python way". I am very impressed though as I got something going extremely quickly and with less messing about than I would have had with C. > I think that may be OK - it's been a while since I played with Python Thanks for your help. Did something about Python turn you away, did you drop it for something better, or are you forced to use something else? Just curious. Thanks, Andy
