Showmedo is financed by a subscription club, membership of which grants access to all of our 160+ specially produced videos. These include our 50 video introduction to Python programming, and our recently completed Open-office migration collection.
(Showmedo is undergoing major changes. To
report any problems viewing the videos please
email us and include
browser and OS specifics. Cheers - Kyran.)
This second video about decorators is going to show you a real-world example on how they can be used.
A decorator is marking functions as deprecated.
Sorry for the abrupt end, though I went on just trying to find out how to enable line-numbers. And yes, the line-number is right.
def new_func(*args, **kwargs):
warnings.warn("This function is old", DeprecationWarning,
return func(*args, **kwargs)
def i_am_old(foo, bar):
return foo, bar
func.__doc__ = docstring
#@change_doc("My super-new docstring")
""" My old docstring """
foo = change_doc("My super-new docstring")(foo)
if __name__ == '__main__':
print i_am_old(42, "Answer")
Are you learning Python? To keep the site running clean and ad-free we've started Club ShowMeDo. The club will allow you access to some special videos we're making to pass on programming skills we consider important to the development and enjoyment of Free Open Source Software (FOSS).
The focus at the moment is on developing with the Python programming language, one of the backbones of the FOSS movement with a huge number of included and third-party libraries.
We welcome feedback and we want to hear your ideas.
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.