Python Tutorial: Duck Typing and Asking Forgiveness, Not Permission (EAFP)

///Python Tutorial: Duck Typing and Asking Forgiveness, Not Permission (EAFP)

Python Tutorial: Duck Typing and Asking Forgiveness, Not Permission (EAFP)

FavoriteLoadingAdd to favorites

In this Python Tutorial, we will look at a couple of the aspects of being “Pythonic”. If you’ve never heard the term Pythonic before, basically it means that you are following conventions and coding styles of the Python language in order to write clean and readable code.

In this video we’ll specifically be looking at two aspects of being Pythonic, and those are “Duck Typing” and the concept that it is easier to ask forgiveness than permission (EAFP). Let’s get started.

The code from this video can be found at:

If you enjoy these videos and would like to support my channel, I would greatly appreciate any assistance through my Patreon account:

Or a one-time contribution through PayPal:

If you would like to see additional ways in which you can support the channel, you can check out my support page:

You can find me on:
My website –
Facebook –
Twitter –
Google Plus –
Tumblr –

By |2017-05-20T21:34:43+00:00May 20th, 2017|Python Video Tutorials|21 Comments


  1. Elgin Cahangirov May 20, 2017 at 9:34 pm - Reply

    Great video! But I have a question. What about performance? Is try.. except.. method is faster than if.. else.. statements or vice versa?

  2. dineshdharme May 20, 2017 at 9:36 pm - Reply

    Can you create some videos based on the ideas collected here :

  3. Ankush Thakur May 20, 2017 at 9:37 pm - Reply

    Hey, which color scheme are you using? 🙂

  4. malhar jajoo May 20, 2017 at 9:38 pm - Reply

    The explanation was good but felt the motivation wasnt clear , like why we would like to take this approach

  5. techNOMAD May 20, 2017 at 9:42 pm - Reply

    You have a God given, natural talent for teaching, especially for Python. I can’t get enough of your videos. Please, please make as many as you can. I’ve subscribed and will probably ‘like’ them all. Thank you!

    BTW: Can you make another video that details your particular environment for optimal debugging Python code with Sublime? What is your solution for doing break points, variable checking, etc.? Thank you again so much.

  6. Just Anthony May 20, 2017 at 9:46 pm - Reply

    Coming from PHP, this vid is one of the sweetest 15 mins in my life. Thank you.

  7. Ivandro Ismael May 20, 2017 at 9:50 pm - Reply

    thank you

  8. BWV 656 May 20, 2017 at 9:51 pm - Reply

    I find your videos really helpful. when you get a chance can you do a tutorial on orderedDict in python? I would love to hear your opinion before i start using it in my script. Thanks you so much!

  9. Ivan Geronimo Bodnar May 20, 2017 at 9:53 pm - Reply

    Another great explanation, thanks

  10. Sam Chan May 20, 2017 at 9:53 pm - Reply

    Thanks,Schafer. It ‘s been a great help for me.

  11. Kopuz May 20, 2017 at 9:54 pm - Reply

    Very good info here, thanks.

  12. Hugo Doucet May 20, 2017 at 9:57 pm - Reply

    Thank you for sharing this philosophy. This has been a great help for me.

  13. Matias Daneri May 20, 2017 at 9:59 pm - Reply

    Could you do a video explaining how to use python base api? PD: Great videos!

  14. Monkey D Luffy May 20, 2017 at 9:59 pm - Reply

    Nice and clear explanation

  15. Михаил Павлов May 20, 2017 at 10:07 pm - Reply

    Very interesting and this concept is new for me. Please keep up on your videos.

  16. royalpranay May 20, 2017 at 10:10 pm - Reply

    Thanks for the tutorials.
    I also have a small question regarding EAFP, What if I don’t want my program to stop execution?
    Shouldn’t it be better to "Ask Permission" and if not allowed, the program should continue further execution.

  17. SeekHeart May 20, 2017 at 10:16 pm - Reply

    another example of pointing out something not pythonic is not using a list comprehension when it’s appropriate.

  18. ArJuN S. May 20, 2017 at 10:16 pm - Reply

    Thanks for explaining such concepts Corey, You should better know that their isn’t anyone who is teaching as good as you. Your channel could just take off once it gets visibility on youtube. Loved your channel!

  19. SHRIKANT DANGI May 20, 2017 at 10:22 pm - Reply

    nicely explained

  20. Mohan Kadolkar May 20, 2017 at 10:28 pm - Reply

    Excellent training. Individual concepts are clearly brought out with examples. God bless u.

  21. Rajesh R May 20, 2017 at 10:32 pm - Reply

    I have learned a lot in Python from your videos than my online courses. A ton of thanks to you.

Leave A Comment