Way in Python to make vars visible in calling method scope? -


I am getting myself to do something which drag RGR to Vars:

  some_var = self.request.get ('some_var', none) other_var = self.request.get ('other_var', none) if no one in [some_var, other_var]: logging. Terror ("some RG" Request.path) exit ()  

What I really want to do:

  pull_ararge ('some_var', 'other_var' )  

And by any means by dragging these variables, or entering an error to be available in the current scope, and if not (or if possible, return to the calling method Return). Is it possible in Python? First, a disclaimer: in any local area, the "drag" variable var =

actually really actually is not recommended it really makes your code confusable for someone what you do Are not well-acquainted with (that is, who is not you, or in the future, which 6 months you are, etc.)

It is being said, only education Costs for tax purposes, in a way. Your pull_args function can be implemented in such a way:

  def pull_args (requests, * args): dragged {try}: for an ARG: Pulled [a] = request besides attribute [A]: Logging. Terror ("Some RG" was missing in + self.request.path) Exit () and: caller = inspect.stack () [1] [0] caller.f_locals.update (pulled)  

At least, did some work for that effect when I came about it about a year ago. I do not necessarily rely on continuing to work in Python versions of the future. (Yet another reason is not this) I personally have not found any good reason to use this code snippet.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -