Question: I am using Perforce 2015 client (P4V) on Windows 7.

I changed some files in my IDE. Then I use "Folder Diff" in Perforce to locate them. I was expecting to find "checkout" right click menu on the "Folder Diff" Perforce window in order to move my changes to a changeset but I don't see any "checkout" around.

How can I checkout directly from Diff view?

Answer: 
If you know the function name, you can run exec on the string. Eval will not work as it only targets expressions. See [\r\n vs \n in python eval function](https://stackoverflow.com/questions/1204376/r-n-vs-n-in-python-eval-function). If you don't know the function name, but all your function have the same format you can try something like this:

```
def extract_function_from_string(content):
    exec(content)
    start = 4
    end = content.find("(")
    function_name = content[start:end]
    return eval(function_name)
my_function = extract_function_from_string("def my_function(x):\n    return x**2")
print my_function(5)

```

The train has left the safe and sound python station a long time ago, but I guess this is just a curiosity.
Here is something that does not leave safe train of python completely.

```
def extract_function_from_string(content, function_index=0):
    import ast
    tree = ast.parse(content, mode='exec')
    function = tree.body[function_index]
    module = ast.Module([function])
    exec(compile(module, filename="<ast>", mode='exec'))
    return locals()[function.name]

content = "def my_function(x):\n    return x**2"
my_function = extract_function_from_string(content) # extract_function_from_string ???
print(my_function(5)) # prints 25

```