Python exception from module

Discussion in 'Programming & Software Development' started by 7nothing, Nov 24, 2019.

  1. 7nothing

    7nothing Member

    Joined:
    Feb 15, 2002
    Messages:
    1,466
    Location:
    Brisbane
    So I tried asking in python-forum.io but the mod who was kind enough to answer my question seems to have learning difficulties. New to python, done years worth of php.

    I'm using someone else's module: pdftitle, if it throws any exception, I want to quietly give up and move on to the next PDF.

    Code:
    import pdftitle
    FilePath = "c:\somepdf.pdf"
    try:
        PdfTitle = pdftitle.run(FilePath)
    except:
        print("an exception occurred")
    ...doesn't catch any of the variety of exceptions when pdftitle (or one of the modules it uses, getting a mix of pdfminer.pdffont.PDFUnicodeNotDefined and recursion limit exceeded for PDFs it doesn't like) throws one.

    I am seeing an "During handling of the above exception, another exception occurred:" in the exception. Is it that which stops my try/except from catching, something about the nesting? How do I make it shut up?
     
  2. OP
    OP
    7nothing

    7nothing Member

    Joined:
    Feb 15, 2002
    Messages:
    1,466
    Location:
    Brisbane
    Ok so I was properly retarded. ...actually drunk.

    Had commented out a chunk of the pdftitle run() function to pass the file name to it. Which worked when it worked, clearly didn't when it failed.

    Not directly related, but have to blame python, since it's a language based on indent (which should be tab, but it's 4 spaces, just ask Richard Hendricks) but the IDE doesn't support shift + tab?
     
  3. Quadbox

    Quadbox Member

    Joined:
    Jun 27, 2001
    Messages:
    6,272
    Location:
    Brisbane
    so... use a better IDE?
     
  4. OP
    OP
    7nothing

    7nothing Member

    Joined:
    Feb 15, 2002
    Messages:
    1,466
    Location:
    Brisbane
    Point was, the Python bundled IDE is not optimized for Python.
     
  5. GumbyNoTalent

    GumbyNoTalent Member

    Joined:
    Jan 8, 2003
    Messages:
    7,972
    Location:
    Briz Vegas
    python doesn't come bundled with anything, its not python language fault you installed a POS IDE, use test editor which meets your needs.
     
  6. becubed

    becubed Member

    Joined:
    Jan 16, 2002
    Messages:
    544
    Idle?
     
  7. OP
    OP
    7nothing

    7nothing Member

    Joined:
    Feb 15, 2002
    Messages:
    1,466
    Location:
    Brisbane
    Sorry you'll have to speak up, I can't hear you over the noise of the self-described python integrated development environment that was included in the install

    Click to view full size!
     
  8. GumbyNoTalent

    GumbyNoTalent Member

    Joined:
    Jan 8, 2003
    Messages:
    7,972
    Location:
    Briz Vegas
    https://docs.python.org/3/library/idle.html?highlight=idle
    Well I'll be a mutha...er, what a piece of shit, but I suppose you use Windows Wordpad for writing all your documents as well so fair call.
     
  9. OP
    OP
    7nothing

    7nothing Member

    Joined:
    Feb 15, 2002
    Messages:
    1,466
    Location:
    Brisbane
    I didn't scroll all the way through the matches, is there one where it outlines why they wrote their own IDE without supporting the established shortcut for fundamental indentation?

    If I installed the wordpad toolkit and it created its own document association with wordpad, and that was flawed... I guess I wouldn't bother cos that's wordpad.
     
    Last edited: Nov 27, 2019
  10. neRok

    neRok Member

    Joined:
    Aug 19, 2006
    Messages:
    3,392
    Location:
    Perth NOR
    Who cares. It's an old POS from when Python was really trying to be an all in one programming language. The established shortcuts probably weren't so established 20 years ago. Yet, if you look in the Format menu, you will see it has indent and dedent shortcuts, and you can change them in the options.

    Or, just install vscode like a normal person.
     

Share This Page

Advertisement: