Unless you would like to start multiple versions of the same kernel or link a language module to a kernel that is not recognized by SoS, you can start a subkernel simply by selecting the language from the language dropdown to the top right corner of each cell.
The SoS language is based on Python 3.6+ so any python statements are acceptable
In [1]:
filename = '1_Expand_and_Capture.ipynb'
In [2]:
wc -l 1_Expand_and_Capture.ipynb
With magic %expand
, cell content is expanded as Python f-string before sending to the subkernel
In [3]:
%expand
wc -l {filename}
In [4]:
%expand
var fs = require('fs');
JSON.parse(fs.readFileSync("{filename}", 'utf8'));
Out[4]:
In [5]:
%capture --to res
%expand
wc -l {filename}
In [6]:
res
Out[6]:
In [7]:
%capture html --to result
%endpoint http://dbpedia.org/sparql
%display table
SELECT DISTINCT ?property
WHERE {
?s ?property ?person .
?person rdf:type foaf:Person .
}
LIMIT 3
In [8]:
from bs4 import BeautifulSoup as Soup
html = Soup(result, 'html.parser')
[a['href'] for a in html.find_all('a')]
Out[8]: