If I have a file, say first.py, which looks like this -
class Person(object): pass class Dog(object): pass and I have a second file, second.py. How can I get all the classes that were defined in first.py in second.py?
Perhaps I should mention that the use-case I'm trying to implement is similar to the one that happens when initializing models in Django - When I run the manage.py sql myapp command, I assume Django goes through all my models in models.py and generates an SQL query for them.
So what I'm trying to do is similar to what Django does when it takes all models defined in models.py.
How can I get all the user defined classes from a file? (Unless there's a smarter way to do what Django does)
Thanks in advance!
class PersonCustom,DogCustom, etc., or give each one an attribute that defines it as something that will be dynamically collected later on.