Methods
Next, I present all methods used in py4pd
object. The methods are messages that you can send to the object. The methods are:
-
It loads the
Python
function. -
To install packages.
pip install
install packages,pip target
which folder install the packages. -
It runs the
Python
function. -
On/Off the Python Data output.
-
Print the documentation of the
Python
function. -
Open a loaded script.
-
Set the editor to open Python Scripts.
-
Create a new
.py
script. -
Reload the Python Function.
-
Set the Python Home folder.
-
Set the Python Packages folder (where Python searches for Packages).
-
Print the Version of
py4pd
and Python.
set
set
Set the function for the object.
-
Arguments
Parameters Type Description arg1
symbol
Python Script name (never uses arg2
anything
Args for the function -
Example
Tip
If you will always use the same function, you can create the object with the
py4pd script function
.
pip
pip
When you set
some function and see some error related to ModuleNotFoundError:
No module named some module, you
need to use pip
to install this module.
-
Arguments
Parameters Type Description arg1
symbol
must be install
arg2
modulename
Module name to install Note
You can also use
pip target
to change the folder wherepy4pd
will install the modules.pip target local
will install the modules inside the patch folder.pip install global
will install in the py4pd folder. Global installations are the default. -
Example
run
run
Used to run the Python Functions.
-
Arguments
Parameters Type Description Arguments
anything
Arguments for the function -
Example
pointers
pointers
You can work with Python Data types inside PureData. With this, you can work with any data type provided by Python inside PureData.
-
Arguments
Parameters Type Description on/off
1
or0
1
for on0
for off -
Example
doc
doc
It prints on PureData the documentation of the Python Function (if it exists).
-
Arguments
There is no Arguments.
Note
The creator of the function must provide some documentation.
-
Example
open
open
It opens py
script files, in case the file does not exist in the patch folder, it creates a new Python Script. open score
, for example, will open the score.py
(if it exists) or create score.py
.
-
Arguments
Parameters Type Description args
symbol
script file name without extension .py
. -
Example
create
create
It creates a new script in the patch folder.
-
Arguments
Parameters Type Description args
symbol
script file name without extension .py
. -
Example
editor
editor
Without arguments, it opens the Python Script loaded with the message set
. With one symbol args, you can choose between four IDE: vscode
, nvim,
emacs, or
sublime`. The function must be loaded first.
-
Arguments
Parameters Type Description arg1
symbol
vscode
,nvim
,emacs
andsublime
. -
Example
Tip
If a function is loaded, clicking on the object will open the loaded function too.
reload
reload
If you are working on a Python Script and changing the code, you need to send this message to the py4pd
for the changes to be loaded.
-
Arguments
There are no Arguments.
-
Example
home
home
Set the home for Python. It is similar to executing Python from some specific folder. For example, when we use cd Downloads
then python myscript.py
in the same terminal.
-
Arguments
Parameters Type Description arg1
symbol
Folder that will be the HOME
for Python Script. -
Example
packages
packages
Set the package path for Python. py4pd
will look for external modules inside these folders. For example, if you have one virtual environment called composition`` with miniconda, you can send
packages ~/miniconda3/envs/composition/lib/python3.11/site-packages` to use the installed packages.
-
Arguments
Parameters Type Description arg1
symbol
Folder that will be the HOME
for Python packages. -
Example
version
version
Output the version of the installed py4pd
and the version of Python
.
-
Arguments
There is no Arguments.
-
Example