¡@

Home 

python Programming Glossary: dynamo

Dynamic/runtime method creation (code generation) in Python

http://stackoverflow.com/questions/533382/dynamic-runtime-method-creation-code-generation-in-python

example class Viking object def __init__ self code ''' def dynamo self arg dynamo's a dynamic method self.weight 1 return.. object def __init__ self code ''' def dynamo self arg dynamo's a dynamic method self.weight 1 return arg self.weight '''.. 50 d exec code.strip in d setattr self.__class__ 'dynamo' d 'dynamo' if __name__ __main__ v Viking print v.dynamo 10..

Django dynamic model fields

http://stackoverflow.com/questions/7933596/django-dynamic-model-fields

using Michael Halls lib your code will look like this from dynamo import models test_app created models.DynamicApp.objects.get_or_create.. created models.DynamicApp.objects.get_or_create name 'dynamo' test created models.DynamicModel.objects.get_or_create name..