Re: NameError: how to get the name?

2010-04-25 Thread Chris Rebert
On Sat, Apr 24, 2010, Yingjie Lan lany...@yahoo.com wrote: On Sun, 4/25/10, Chris Rebert c...@rebertia.com wrote: On Sat, Apr 24, 2010, Yingjie Lan lany...@yahoo.com wrote: On Sat, 4/24/10, Gary Herron gher...@islandtraining.com wrote: Yingjie Lan wrote: On Sat, 4/24/10, Steven D'Aprano

Re: NameError: how to get the name?

2010-04-25 Thread Yingjie Lan
--- On Sun, 4/25/10, Chris Rebert c...@rebertia.com wrote: From: Chris Rebert c...@rebertia.com Subject: Re: NameError: how to get the name? To: Yingjie Lan lany...@yahoo.com Cc: python list python-list@python.org Date: Sunday, April 25, 2010, 10:09 AM On Sat, Apr 24, 2010, Yingjie Lan

NameError: how to get the name?

2010-04-24 Thread Yingjie Lan
I wanted to do something like this: while True: try: def fun(a, b=b, c=c): pass except NameError as ne: name = get_the_var_name(ne) locals()[name] = '' else: break What's be best way to implement the function get_the_var_name(ne) that returns the name of the variable that

Re: NameError: how to get the name?

2010-04-24 Thread James Mills
On Sat, Apr 24, 2010 at 9:19 PM, Yingjie Lan lany...@yahoo.com wrote: I wanted to do something like this: while True:  try:    def fun(a, b=b, c=c): pass  except NameError as ne:    name = get_the_var_name(ne)    locals()[name] = ''  else: break What's be best way to implement the

Re: NameError: how to get the name?

2010-04-24 Thread Steven D'Aprano
On Sat, 24 Apr 2010 04:19:43 -0700, Yingjie Lan wrote: I wanted to do something like this: while True: try: def fun(a, b=b, c=c): pass except NameError as ne: name = get_the_var_name(ne) locals()[name] = '' else: break This won't work. Writing to locals() does not

Re: NameError: how to get the name?

2010-04-24 Thread Yingjie Lan
--- On Sat, 4/24/10, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: From: Steven D'Aprano st...@remove-this-cybersource.com.au Subject: Re: NameError: how to get the name? To: python-list@python.org Date: Saturday, April 24, 2010, 4:07 PM On Sat, 24 Apr 2010 04:19:43 -0700

Re: NameError: how to get the name?

2010-04-24 Thread Yingjie Lan
--- On Sat, 4/24/10, James Mills prolo...@shortcircuit.net.au wrote: From: James Mills prolo...@shortcircuit.net.au Subject: Re: NameError: how to get the name? To: Yingjie Lan lany...@yahoo.com Cc: python list python-list@python.org Date: Saturday, April 24, 2010, 4:03 PM On Sat, Apr 24

Re: NameError: how to get the name?

2010-04-24 Thread Gary Herron
Yingjie Lan wrote: --- On Sat, 4/24/10, Steven D'Aprano st...@remove-this-cybersource.com.au wrote: From: Steven D'Aprano st...@remove-this-cybersource.com.au Subject: Re: NameError: how to get the name? To: python-list@python.org Date: Saturday, April 24, 2010, 4:07 PM On Sat, 24 Apr 2010

Re: NameError: how to get the name?

2010-04-24 Thread Yingjie Lan
--- On Sat, 4/24/10, Gary Herron gher...@islandtraining.com wrote: From: Gary Herron gher...@islandtraining.com Subject: Re: NameError: how to get the name? To: Cc: python-list@python.org Date: Saturday, April 24, 2010, 8:03 PM Yingjie Lan wrote: --- On Sat, 4/24/10, Steven D'Aprano st

Re: NameError: how to get the name?

2010-04-24 Thread Chris Rebert
-this-cybersource.com.au wrote: From: Steven D'Aprano st...@remove-this-cybersource.com.au Subject: Re: NameError: how to get the name? To: python-list@python.org Date: Saturday, April 24, 2010, 4:07 PM On Sat, 24 Apr 2010 04:19:43 -0700, Yingjie Lan wrote: I wanted to do something

Re: NameError: how to get the name?

2010-04-24 Thread Yingjie Lan
--- On Sun, 4/25/10, Chris Rebert c...@rebertia.com wrote: From: Chris Rebert c...@rebertia.com Subject: Re: NameError: how to get the name? To: Yingjie Lan lany...@yahoo.com Cc: python-list@python.org Date: Sunday, April 25, 2010, 3:27 AM On Sat, Apr 24, 2010 at 4:17 PM, Yingjie Lan lany