Name: [171] Florian Mayer
Member: 114 months
Authored: 7 videos
Description: I'm a student from Vienna, the federal capital of Austria. Please visit `My Blog <>`_ ...

Decorators: The Basics [ID:877] (1/3)

in series: Advanced Python

video tutorial by Florian Mayer, added 09/08

(Showmedo is undergoing major changes. To report any problems viewing the videos please email us and include browser and OS specifics. Cheers - Kyran.)

This video is going to show you the basics of decorators. A decorator is used to alter the docstring of a function.

def change_doc(docstring):
    def decorator(func):
        func.__doc__ = docstring
        return func
    return decorator

#@change_doc("My super-new docstring")
def foo(bar):
    """ My old docstring """
    return bar

foo = change_doc("My super-new docstring")(foo)

if __name__ == '__main__':
    print foo.__doc__

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 54 (since July 30th)
  • Plays in last week: 2
  • Published: 95 months ago

Thank-yous, questions and comments

If this video tutorial was helpful please take some time to say thank-you to the authors for their hard work. Feel free to ask questions. Let the author know why their video tutorial was useful - what are you learning about? Did the video tutorial save you time? Would you like to see more?

You may also want to see our ShowMeDo Google Group to speak to our active users and authors.

Your email address will not be published.

Show some quick comments >>

All comments excluding tick-boxed quick-comments

20. cheap jordans Thu, 01 Jul 2010 03:07


19. fitflop cheapest Mon, 12 Apr 2010 15:57

Perspicuous. If I were unfamiliar with decorators, I would appreciate brief illustrations of specific situations where you have used them. (Changing __doc__ strings, while simple enough to serve as clear examples, doesn't convey how important decorators can be).

18. ShewenLiny Sat, 10 Apr 2010 16:21

Nice VIdeo,rly.. U speak slowy and clearly. I Understood everything of the Decorators :D... You have to know im German :P

I was having difficulty understanding the concept and implementation of decorators, but your video along with some experimenting helped to clear this up.

Thank you,


I was having difficulty understanding the concept and implementation of decorators, but your video along with some experimenting helped to clear this up.

Thank you,


15. jasa SEO, Backlink, Blogwalking murah Wed, 17 Mar 2010 10:57

thanks -- just learning decorators. Technical note -- I was hanging on last image when this comment page popped up and I lost my train of thought and the image.

14. marinir seo 085-635-945-40 Tue, 09 Mar 2010 01:30

Very clear example, good video. Thanks!

13. Sun, 31 Jan 2010 10:19

You've made decorators' purpose much clearer, thanks! Seems logical to have a meta-level for munging code while running. Rather like adapting to life!

12. anonymous Tue, 13 Oct 2009 20:28

good job. thanks

11. anonymous Sun, 27 Sep 2009 15:43

Very nice intro into Decorators. Cheers!

10. anonymous Sun, 19 Jul 2009 19:49

Hi Florian,

When you showed your results, they were only flashed on the screen for a quick moment before you went back to your original screen. It would have been nice if you could have left that screen up a bit longer. Also it was difficult to know what we were looking at without more explanation. Some sort of screen pointer would be helpful so we would know where to direct our eyes and what portion of an overwhelmingly complex screen image is important for us to pay attention to. It would also be nice to have a bit of introduction at the beginning of what you are planning to show us and what you want to accomplish in showing that to us. Then at the end a short summation of what you had just showed us and what we should take away with us. I also like less abstract examples. Show this in the context of a simple programming idiom we can relate to. (example: functions that compute the board feet in a log. A decorator that adapts that function for different kinds of woods and/or different kinds of prices) Give us some idea where and when we would find a decorator useful. Give us a reason for wanting to use a decorator.


Good Luck,


9. anonymous Wed, 18 Mar 2009 13:58

Great... thanks a lot. Helps me to understand decorators :-)

I got a bunch of "Advanced Python" videos on my harddisk. But I am too lazy to post-process them, for some months now. Once I do that I'll upload videos about lambda, higher-order functions, list comprehensions, generator expressions and so forth. Stay tuned!

More videos on advanced python, please

6. anonymous Sat, 27 Dec 2008 16:24

Nice to have advanced python, there aren't so many!

I have never understood decorators until watching this video. It is starting to make some sense now. Thanks for putting this together.

mind-boggling ! the wing-ide looks really cool, i was not aware that it works under linux.

Oh really? I'm very delighted to hear that.

Be sure to comment on the second video too. Thanks!

was anxiously waiting for this video!

The ShowMeDo Robot says - this video is now published, thanks for adding to ShowMeDo.

Showmedo is a peer-produced video-tutorials and screencasts site for free and open-source software (FOSS)- with the exception of some club videos, the large majority are free to watch and download.

how to help » about » faq »

Educating the Open-source Community With Showmedo

Although as important as the software it supports, education and documentation are relatively neglected in the Open-source world. Coders love to code, and explaining how best to use or improve the software tends to be deferred or even sidelined.

At Showmedo we believe the community can play a vital role here and also say thanks for the tools and software that make our lives easier. If you have a piece of software you love or a programming langugage you are enthusiastic about, why not make a screencast showing others how to use it? All the stuff you wish you'd been told, the tips, tricks, insights that would have saved you time and frustration.

Screencasting is easier than you think, and we're happy to help you. You can emailus for advice or just use some of the how-to screencasts on the site. This screencasting learning-pathis a good place to start.

Kudos and Thanks for Florian

Decorators: Introducing functools.wraps


maccosmeticswholesalers mac makeup pencil c 17
72 months ago


Showmedo's development is fairly rapid and bugs will inevitably creep in. If you have any problems please drop us a line using the contact address below. Likewise, any suggestions for improvements to the site are gratefully received.