Re: Handling NameError in a list gracefully

2009-04-20 Thread Terry Reedy
Jesse Aldridge wrote: from my_paths import * def get_selected_paths(): return [home, desktop, project1, project2] --- So I have a function like this which returns a list containing a bunch of variables. The real list has around 50 entries. Occasionally I'll remove a variable from my_

Re: Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
On Apr 20, 3:46 pm, Chris Rebert wrote: > On Mon, Apr 20, 2009 at 1:36 PM, Jesse Aldridge > wrote: > > from my_paths import * > > > def get_selected_paths(): > >    return [home, desktop, project1, project2] > > > --- > > > So I have a function like this which returns a list containing a bun

Re: Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
Nevermind, I figured it out right after I clicked the send button :\ from my_paths import * def get_selected_paths(): return [globals()[s] for s in ["home", "desktop", "project1", "project2"] if s in globals()] -- http://mail.python.org/mailman/listinfo/python-list

Re: Handling NameError in a list gracefully

2009-04-20 Thread Chris Rebert
On Mon, Apr 20, 2009 at 1:36 PM, Jesse Aldridge wrote: > from my_paths import * > > def get_selected_paths(): >    return [home, desktop, project1, project2] > > --- > > So I have a function like this which returns a list containing a bunch > of variables.  The real list has around 50 entries.

Handling NameError in a list gracefully

2009-04-20 Thread Jesse Aldridge
from my_paths import * def get_selected_paths(): return [home, desktop, project1, project2] --- So I have a function like this which returns a list containing a bunch of variables. The real list has around 50 entries. Occasionally I'll remove a variable from my_paths and cause get_sele