On Thursday, 26 July 2012 00:45:09 UTC+1, Michael Bayer wrote:
>
>
> my_list_of_classes = make_classes(my_list_of_1000_names)
>
> you've got this use case where you have 1000 names to make into classes.   
> Do you want to use them by name in a dynamic way ?  OK, put them in a dict:
>
> my_dict = dict((c.__name__, c) for c in my_list_of_classes)
>
> session.query(my_dict["SomeName"]).all()
>
> do you want to import them from a module ?  OK, then put them in the 
> module:
>
> from myapp import somemodule
> for cls in my_list_of_classes:
> setattr(somemodule, cls.__name__, cls)
>
> # later
>
> from myapp.somemodule import Cls1234
> session.query(Cls1234).all()
>


Yes, this is exactly what I was looking for. Thanks, and sorry about the 
confusion. 

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sqlalchemy/-/fytMnE3kEucJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to