[Edu-sig] demented Python...

kirby urner kirby.urner at gmail.com
Sat Apr 2 20:16:44 CEST 2011


In calling something "demented" I'm coming off
the namespace used around genres of cartoon.

Cartoons I'd consider demented:

Pinky and the Brain
Ren and Stimpy
Teenage Aqua Hunger Force (Kevin Altis of PythonCard a fan)
SpongeBob SquarePants
...


(see clips on Youtube for any/all)

Synonyms for demented:  zany, surreal

Relevant:  links to "grossology" in EuroPython
presentation:

http://www.4dsolutions.net/presentations/connectingthedots.pdf
(see string.Template Mad Libs)

Likewise, Demented Python serves a didactic function,
here to remind about the decorator:

def sillystrip( f ):
    if f.__doc__:
        f.__doc__ = "Your function has been hacked!"
    else:
        f.__doc__ = "You should always have a docstring."
    return f

@sillystrip
def square( x ):
    """could also be a triangle"""
    return x * x

def _test():
    frank = 2
    joe = square (frank)  # frank is kinda square
    print("Hello Joe, Frank here.")
    print(square.__doc__)

if __name__ == "__main__":
    _test()

Usage:

>>> ================================ RESTART
================================
>>>
Hello Joe, Frank here.
Your function has been hacked!

Then comment out the docstring in the def of square.

>>> ================================ RESTART
================================
>>>
Hello Joe, Frank here.
You should always have a docstring.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/edu-sig/attachments/20110402/1451e474/attachment.html>


More information about the Edu-sig mailing list