m2m模型翻译
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

12 lines
400 B

6 months ago
  1. """Functions that involve magic. """
  2. def pollute(names, objects):
  3. """Pollute the global namespace with symbols -> objects mapping. """
  4. from inspect import currentframe
  5. frame = currentframe().f_back.f_back
  6. try:
  7. for name, obj in zip(names, objects):
  8. frame.f_globals[name] = obj
  9. finally:
  10. del frame # break cyclic dependencies as stated in inspect docs