There are two optional clauses used in try except statements:
1. Else clause: It is useful for code that must be executed when the try block does not create any exception
2. Finally clause: It is useful for code that must be executed irrespective of whether an exception is generated or not.
Add u before the string
>>> u 'test'
List comprehensions help to create and manage lists in a simpler and clearer way than using map(), filter() and lambda. Each list comprehension consists of an expression followed by a clause, then zero or more for or if clauses.
Python can run of every operating system like UNIX/LINUX, Mac, Windows, and others.
Pass is a no-operation/action statement in python
If we want to load a module and if it does not exist, let us not bother, let us try to do other task. The following example demonstrates that.
Try:
Import module1
Except:
Pass
Webmaster 23rd of May 2012
Tell us what you feel about Python Interview Questions and Answers
All comments will be published after review. No login or registration is required to post a comment on Python Interview Questions and Answers We offer and invite you to submit your valuable comment now; Please be respectful of others when commenting. Insulting others, self-promotional comments, website promotional comments, marketing stuff, SEO Techniques, SMS-style content and off-topic comments will not be approved at this information portal.
So start sharing your thoughts regarding Python Interview Questions and Answers
Thank you.