On 30 Apr, 12:36, "Diez B. Roggisch" <de...@nospam.web.de> wrote: > Mark Tarver wrote: > > In Lisp this is done so > > >> (setq *g* 0) > > 0 > > >> *g* > > 0 > > >> (makunbound '*g*) > > *g* > > >> *g* > > error: unbound variable > > > How is this done in Python? > > > Mark > >>> foo = "bar" > >>> del foo > >>> foo > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > NameError: name 'foo' is not defined > > > > Be aware of functions that declare global variables though: > > >>> def foo(): > > ... global bar > ... bar = 10 > ...>>> foo() > >>> bar > 10 > >>> del bar > >>> bar > > Traceback (most recent call last): > File "<stdin>", line 1, in <module> > NameError: name 'bar' is not defined>>> foo() > >>> bar > > 10 > > Diez- Hide quoted text - > > - Show quoted text -
Great; and how can I test to see if a global is bound? e.g Lisp > (setq *g* 0) 0 > (boundp '*g*) t Mark -- http://mail.python.org/mailman/listinfo/python-list