Zeynel wrote: > I want to append new input to list SESSION_U without erasing its > content. I try this: > > ... > try: > SESSION_U.append(UNIQUES) > except NameError: > SESSION_U = [] > SESSION_U.append(UNIQUES) > ... > I would think that at first try I would get the NameError and > SESSION_U list would be created and appended; the second time try > would work. But it does not. Do you know why?
If you want SESSION_U to be global you must say so. E. g.: def your_func(): global SESSION_U # ... > try: > SESSION_U.append(UNIQUES) > except NameError: > SESSION_U = [] > SESSION_U.append(UNIQUES) # ... Of course I'm only guessing because you don't provide enough context. Peter -- http://mail.python.org/mailman/listinfo/python-list