braver wrote: > A symbol which is a unique string is not the story here, it turns out > -- dynamic language is! > > has_many :milestones > > is apparently a call which generates code inside of the class! Can it > be replicated in python for ORM purposes? > >
Not really. Read up on metaclasses and how classes are created in python. In ruby, functions in a class block get the class as a first argument, AFAICT. In python they don't. So the closest semantically would be: class Whatever(Model): pass has_many(Whatever, "milestones") Not very compelling. The closest hack would be: class Whatever(Model): c = C() c.has_many("milestones") with a metaclass that sucks up all the crap invoked on c. Personally, I think class attributes are fine.