Call Methods on Python Variables

This example shows how to update a Python® list of folder names using the append method.

Create a list of folders P using the Python sys.path variable.

P = py.sys.path;

Display the Python functions for a list type.

methods(P)
Methods for class py.list:

append   count    ge       insert   lt       plus     reverse  
cell     eq       gt       le       mtimes   pop      sort     
char     extend   index    list     ne       remove   

Methods of py.list inherited from handle.

Read the documentation for append.

py.help('list.append')
Help on method_descriptor in list:

list.append = append(...)
    L.append(object) -- append object to end

Add the current folder to the end of the path.

append(P,pwd)

Display the number of folders on the path. The list has py.len elements. Your value might be different. The type of this number is py.int.

py.len(P)
ans = int64
    10

Related Topics