Re: Existance of of variable

2005-07-13 Thread Andreas Kostyrka
Am Montag, den 04.07.2005, 20:25 -0400 schrieb Roy Smith: > Steven D'Aprano <[EMAIL PROTECTED]> wrote: > > Should we *really* be encouraging newbies to mess with globals() and > > locals()? Isn't that giving them the tools to shoot their foot off before > > teaching them how to put shoes on? > > W

Re: Existance of of variable

2005-07-04 Thread Roy Smith
Steven D'Aprano <[EMAIL PROTECTED]> wrote: > Should we *really* be encouraging newbies to mess with globals() and > locals()? Isn't that giving them the tools to shoot their foot off before > teaching them how to put shoes on? Why risk damaging perfectly good footwear? But, seriously, I agree wit

Re: Existance of of variable

2005-07-04 Thread Steven D'Aprano
On Mon, 04 Jul 2005 21:17:21 +0200, tiissa wrote: > Josiah Manson wrote: >> Hello. I am very new to Python, and have been unable to figure out how >> to check if a variable exists or not. In the following code I have made >> a kludge that works, but I think that it would be clearer to check if >>

Re: Existance of of variable

2005-07-04 Thread Terry Reedy
"tiissa" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Variables are stored in two dictionnaries: globals() (for global > variables) and locals() (for the local ones, which are also global on > top level). Within a function, the local namespace is usually *not* a dictionary. D=lo

Re: Existance of of variable

2005-07-04 Thread Benjamin Niemann
George Sakkis wrote: > Hi Josiah, > >> Hello. I am very new to Python, and have been unable to figure out how >> to check if a variable exists or not. In the following code I have made >> a kludge that works, but I think that it would be clearer to check if >> closest exists and not have to initi

Re: Existance of of variable

2005-07-04 Thread George Sakkis
Hi Josiah, > Hello. I am very new to Python, and have been unable to figure out how > to check if a variable exists or not. In the following code I have made > a kludge that works, but I think that it would be clearer to check if > closest exists and not have to initialize it in the first place. H

Re: Existance of of variable

2005-07-04 Thread Terry Reedy
"Josiah Manson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello. I am very new to Python, and have been unable to figure out how > to check if a variable exists or not. In the following code Python does not have variables is the sense some other languages do. It has (typele

Re: Existance of of variable

2005-07-04 Thread Peter Otten
Josiah Manson wrote: > Hello. I am very new to Python, and have been unable to figure out how > to check if a variable exists or not. In the following code I have made try: variable except NameError: # variable doesn't exist else: # variable exists But it is rare that you actually ne

Re: Existance of of variable

2005-07-04 Thread tiissa
Josiah Manson wrote: > Hello. I am very new to Python, and have been unable to figure out how > to check if a variable exists or not. In the following code I have made > a kludge that works, but I think that it would be clearer to check if > closest exists and not have to initialize it in the first

Existance of of variable

2005-07-04 Thread Josiah Manson
Hello. I am very new to Python, and have been unable to figure out how to check if a variable exists or not. In the following code I have made a kludge that works, but I think that it would be clearer to check if closest exists and not have to initialize it in the first place. How is that check don