Created
December 26, 2011 08:13
-
-
Save kipanshi/1520747 to your computer and use it in GitHub Desktop.
Acessing global namespace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assume you have model ``Project`` with 1:M relation to ``Task`` | |
# here ``p`` instance of ``Project``, and it has some amount of tasks | |
# Following inline is creating global variable ``t<idx>`` for each task (e.g. t1, t2, ...) | |
[globals().update({'t%s' % (idx + 1): t}) for idx, t in enumerate(p.tasks.all())] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment