Re: NoneType Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?utf-8?q?C=C3=A9dric_Lucantis?=

    Re: NoneType Error

    Hi,

    Le Sunday 15 June 2008 10:35:18 Maryam Saeedi, vous avez écrit :
    I am using a python program on a lot of different documents and for few of
    them I will get NoneType error. I just want to skip those files and
    continue for others, I do this without a problem for
    IndexError,Type Error,ValueErro r,NameError :
    >
    try:
    ....
    except (IndexError,Typ eError,ValueErr or,NameError):
    ....
    >
    but when I add NoneType it gives the following error:
    except (NoneType,Index Error,TypeError ,ValueError,Nam eError):
    NameError: name 'NoneType' is not defined
    >
    and if I do not use the NoneType then it does not go through either and
    stops the program when I get to such a file. Is there another name that
    captures this error?
    >
    Thanks for your help,
    >
    Maryam
    you can get the none type with None.__class__ or with the 'types' module, but
    it won't work as the except handler only accepts Exception classes. It sounds
    like you're confusing with some other error, what is the exact message of
    your 'NoneType error' ? The exception type you want to catch should be at the
    beginning of it (as in 'TypeError: blah blah...')

    --
    Cédric Lucantis
Working...