Dino Viehland wrote:
On option 1 is this legal then?

x = float(string) except float('nan') if some_check() else float('inf') if 
ValueError

Well, is this is legal?

    try:
        x = float(string)
    except some_check():
        x = float('nan')
    except ValueError:
        x = float('inf')

In other words, some_check() returns an exception _class_.

>>> def get_exception():
    return ValueError

>>> try:
    x = float("")
except get_exception():
    print "not a float"


not a float

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to