IPythonDictionary.Values

Syntax

Values: IPythonList;

Description

The Values property returns the list of all dictionary values.

Example

Executing the example requires a folder with modules: d:\Work\Python\. The folder contains the sample.py module. The following function is implemented in the module:

def getNewDictionary(count):

d = {a: a ** 2 for a in range(count)}

return d

Add a link to the Python system assembly.

Sub UserProc;
Var
    pUtils: IPythonUtils;
    pDict: IPythonDictionary;
    Result: Variant;
    KeyList, ValList: IPythonList;
    i, c: Integer;
Begin
    pUtils := 
New PythonUtils.Create;
    pUtils.AddFolderToPythonPath(
"d:\Work\Python\");
    
// Get dictionary, which is a result of function execution
    Result := pUtils.Invoke("sample""getNewDictionary"10);
    
// Create a dictionary from obtained result of the getNewDictionary function
    pDict := New PythonDictionary.Create(Result);
    KeyList := pDict.Keys;
    ValList := pDict.Values;
    c := pDict.Length;
    
// View existing key-value pairs
    For i := 0 To c - 1 Do
        Debug.WriteLine(
"Key: " + KeyList.Item(i) + "; Value: " + ValList.Item(i));
    
End For;
End Sub UserProc;

After executing the example the getNewDictionary Python function will be executed. This function returns the generated dictionary with ten key-value pairs. The obtained keys and values will be displayed in the development environment console.

See also:

IPythonDictionary