Created
January 27, 2012 23:06
-
-
Save capttwinky/1691452 to your computer and use it in GitHub Desktop.
How OO is python? ... it's objects, all the way down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| def myFunction(**kwargs): | |
| return attrSetter(myFunction,**kwargs) | |
| def attrSetter(target,**kwargs): | |
| for k,v in kwargs.iteritems(): | |
| setattr(target,k,v) | |
| return True | |
| def main(): | |
| myFunction(**{'a':'apple','b':'bonobo'}) | |
| print myFunction.a | |
| print myFunction.b | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment