Handling NameError in a list gracefully

Jesse Aldridge JesseAldridge at gmail.com
Mon Apr 20 16:46:41 EDT 2009


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()]



More information about the Python-list mailing list