Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 SQLObject 并希望使用 .q 对象(或其他方式)以编程方式构建查询——但不想恢复为实际 SQL。
我正在尝试做类似的事情:
column = 'name' value = 'todd' Users.select(Users.q.column==value)
我有这个:
Users.select(eval('Users.q.%s' % column)==value)
但这只是感觉“错误”——这是“正确”(或更恰当地说,“pythonic”)的方式吗?
Users.select(getattr(Users.q, column)==value)