Syntax for python calls from factor


The python.syntax vocab adds syntax to factor to make calls from factor to python natural and intuitive.
PY-FROM:
PY-QUALIFIED-FROM:
PY-METHODS:



Examples
Here is how you bind and call a method namelist on a ZipFile instance created by importing the zipfile module:
PY-FROM: zipfile => ZipFile ( name mode -- file ) ; PY-METHODS: ZipFile => namelist ( self -- names ) ; ! Then use the declarations like this "name-of-zip.zip" >py "r" >py ZipFile namelist py>

In python, a method or function takes keyword arguments if its last parameter starts with "**". If the name of the last argument to a declared function is "**" then a hashtable can be sent to the function:
PY-FROM: datetime => timedelta ( ** -- timedelta ) ; PY-METHODS: timedelta => seconds ( self -- n ) ; H{ { "hours" 99 } { "minutes" 33 } } >py timedelta $seconds py> . 12780