Dynamically Cause A Function To Return

Kayode Odeyemi dreyemi at gmail.com
Tue Sep 20 14:29:06 EDT 2011


On Tue, Sep 20, 2011 at 12:13 AM, Jordan Evans <mindwalkernine at gmail.com>wrote:

> I want dynamically place the 'return' statement in a function via user
> input or achieve the same through some other means.  If some other means,
> the user must be able initiate this at runtime during a raw_input().  This
> is what I have so far, this would be an awesome command line debugging tool
> if I can get it to work.
>
> def b(label="", *args):
>     """Used to create breaks for debugging.  Will break the function or
> continue the function it is place within based on user input.  Has as a
> input loop for querying variables and executing code before a break or a
> continue."""
>     print label+":",
>     for arg in args:
>         print str(arg),
>     if len(args):
>         print
>     x = ""
>     while x != ".":
>         command = raw_input()
>         try:
>             exec command
>         except:
>             pass
>

Isn't this "call by reference" ?

see
http://docs.python.org/faq/programming.html?highlight=kwargs#how-do-i-write-a-function-with-output-parameters-call-by-reference



-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110920/567944e0/attachment.html>


More information about the Python-list mailing list