-
Notifications
You must be signed in to change notification settings - Fork 96
Problematic behavior of locals() inside a funtion #368
Copy link
Copy link
Closed
Labels
wontfixIndicates that work won't continue on an issue, pull request, or discussionIndicates that work won't continue on an issue, pull request, or discussion
Milestone
Metadata
Metadata
Assignees
Labels
wontfixIndicates that work won't continue on an issue, pull request, or discussionIndicates that work won't continue on an issue, pull request, or discussion
Type
Fields
Give feedbackNo fields configured for issues without a type.
Use of
locals()inside a function leads to unexpected behavior. For an example, the following code snippetCalling the fucntion
make_tables()will result in name resolution error for the foreign key reference-> Ainside the definition ofBdespite the fact that the following works just fine:The problem arise due to the fact that, for some reasons, the dictionary returned by the
locals()do not stay updated when used inside a function. This can be demonstrated by the following code:This makes the use of
locals()highly unreliable inside a function.