1

I'm writing a small parser class for a personal project. The class will essentially parse popular playlist files and return useful information.

Since the class will interact with files, I'm not sure about the best way to handle errors. I'm a Linux guy and generally do things in errno fashion but I'm wondering that whether exceptions are a better selection or not.

In short what's the best way to handle these things in python world?

Thanks in advance.

3
  • 6
    with and exceptions.. Commented Nov 8, 2011 at 13:40
  • 5
    There are some file i/o related examples in the python docs on handling exceptions Commented Nov 8, 2011 at 13:42
  • 2
    Take a look at this example from Dive Into Python. Commented Nov 8, 2011 at 14:24

1 Answer 1

1

You want to use exceptions. And if you are using python 2.7, you want to use the with statement.

There is a good tutorial in the standard python documentation , but there are tons of other recources: wikibooks, dive into python, articles in blogs.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, that answers my question pretty much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.