Join Club ShowMeDo to Learn Python!

This series is a part of Club ShowMeDo. Click to learn why you should join our club with a simple monthly subscription.

  • We teach Python and all the cool modules
  • Topics include beginner Python, GUIs, Web and Desktop Apps
  • Long, specially crafted video tutorials just for you
  • Club video tutorials extend our normal Free content
  • Save your time - we've done the research for you
  • Keep your skills up-to-date
  • Learn at your own pace, everything you need is shown to you
  • Over 12 hours of archived material are waiting for you in the club

Name: [002] Ian Ozsvald
Member: 109 months
Authored: 181 videos
Description: I am the co-founder of ShowMeDo (see http://showmedo.com/about), author of `The Screencasting Handbook <http://thescreencastinghandbook.com>`_ and the founder of the professional screencast production company `ProCasts <http://procasts.co.uk>`_: .. image:: http://procasts.co.uk/media/procasts_sma ...

Defining a Function [ID:920] (2/6)

in series: Python Beginners - Functions

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

Here we start by looking at the simplest Hello World function in Python.

Note that the naming convention is for lowercase and underscores and that docstrings are recommended. Python functions are 'first class' (see wikipedia link below), this means that we can assign them to variables and pass them around - you may not have seen this if you come from a C++/Java background.

Links: naming conventions, docstrings, first class functions.

# Functions 1 using Python 2.5
# 2008/10/22

def hello_world():
    """print Hello! to the screen."""
    # note 4 space indentation
    print "Hello!"

# note naming convention with underscores
# http://www.python.org/dev/peps/pep-0008/
"""Function names should be lowercase, with words separated 
   by underscores as necessary to improve readability.
   mixedCase is allowed only in contexts where that's already 
   the prevailing style (e.g. threading.py), to retain 
   backwards compatibility."""

# generally you always want a docstring as the first line(s)
# of a function using triple-quote strings (multiline)
# http://www.python.org/dev/peps/pep-0257/

# call hello_world function    
hello_world()    

# note that hello_world is a first-class function
# http://en.wikipedia.org/wiki/First-class_function
#print "Python supports first-class functions"
#print hello_world
#print id(hello_world)
#b = hello_world
#b()

Got any questions?

Get answers in the ShowMeDo Learners Google Group.

Video statistics:

  • Video's rank shown in the most popular listing
  • Video plays: 356 (since July 30th)
  • Plays in last week: 0
  • Published: 74 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

Very good. Clear and deals with it crisply


Thank you for this Video!


Very good video.Pace was not too fast.


Second video, the volume issue was fixed. Very good website. Thanks for doing this


Awesome video!! looking forward to more, thanks,


I like the beginner videos, because you are confident on what the student must prepare to accept initially as dogma, and suggest to trust you for later explanation and pragmatize the knowledge-gaps.

You also show the PEPs, as a great way of showing how software is maintained when tenths of thousands of people are behind it.


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


Your video has been edited. This is an automatic post by ShowMeDo.


Your video has been edited. This is an automatic post by 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 Ian

Content

Feedback

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.

feedback@showmedo.com