Exception handling with NameError

Zeynel azeynel1 at gmail.com
Fri Nov 5 14:12:49 EDT 2010


On Nov 5, 1:26 pm, Peter Otten <__pete... at web.de> wrote:

> Of course I'm only guessing because you don't provide enough context.
>
> Peter

Thanks.

This is the problem I am having, in general:

K = []  # a container list
K = ["A", "B"]

ARCHIVE = [] # a list where items from K is archived

ARCHIVE.append(K)

# K is updated
K = ["C", "D"]

# append new K to ARCHIVE
ARCHIVE.append(K)

The problem I am having is this: If I do:

K = []
ARCHIVE = []
ARCHIVE.append(K)

any time K is updated (user submits new input) the content of ARCHIVE
is erased:

If I do this:

K = []
ARCHIVE.append(K)

I get NameError: "Name ARCHIVE not defined"

What is the solution?



More information about the Python-list mailing list