[Edu-sig] demented Python...

Corey Richardson kb1pkl at aim.com
Sun Apr 3 11:39:10 CEST 2011


On 04/02/2011 02:16 PM, kirby urner wrote:
> 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()

Did you see the PyCon2011 video on obfuscating python?
http://blip.tv/file/4881220

-- 
Corey Richardson


More information about the Edu-sig mailing list