Package: netsblox
PyBloxNetsBlox is a block-based programming environment which has a focus on distributed computing and internet connectivity.
One of the core features of NetsBlox areremote procedure calls(RPCs), which connect to the NetsBlox server and provide access to online resources such as databases, GoogleMaps, online translation, wireless robotics, mobile phone sensors/control, and more.PyBlox is an interface for accessing allNetsBloxservices from within python.
You can import this package in any python program that has internet access and begin calling RPCs and sending/receiving messages!For more information about NetsBlox and the available services, see the officialNetsBlox Documentation.Example UsageHere's a short example to see how you can access theMaunaLoaCO2Dataservice from python.importnetsbloxnb=netsblox.Client()# create a client to access NetsBloxdata=nb.mauna_loa_co2_data.get_co2_trend(2000,2010)print(data)Graphical EnvironmentPyBlox, while useful on its own for accessing NetsBlox services, has a side goal of helping transition students from block-based languages like NetsBlox and Snap! into textual languages like python.
Because of this, PyBlox comes with a power graphical environment that supports most of the same features as NetsBlox/Snap!, as well as an IDE for creating python projects in a way that is still structured like a NetsBlox/Snap! project in both appearnance and concurrency model (closest approximation).These features are only activated when explicitly called, leaving the default behavior as a normal python package for accessing NetsBlox services.To launch the IDE, you can simply run PyBlox (netsblox) as a module:python-mnetsbloxInstallationPyBlox is available as a pip package callednetsblox(keep in mind that PyBlox is a python3 package, so you may need to usepip3if yourpipstill points to the python2 version).pipinstallnetsbloxIf you run into installation issues with thenb2pbdependency, follow the instructionhere.
It is possible that there is not a wheel build for your platform and/or python version, which means that it must be compiled from source.
This requires installingcargo, after which you can reattempt installingnetsblox.
If this solves your problem, feel free tosubmit an issueincluding your operating system and processor architecture.The following additional setup is required, depending on your operating system.WindowsNo additional install dependenciesMacbrewinstallpython-tkLinuxsudoaptinstallpython3-pilpython3-pil.imagetk
sudoaptinstallidle3Structured DataDue to the limited type primitives in Snap!, one NetsBlox typing convention is "structured data", which is really just a list of lists (pairs) denoting (unique string) keys and values.
In the python interface, this is replaced bydictfor both input and return value.
The python interface will automatically convert inputdictvalues into lists of lists, and convert lists of lists return values intodict(where appropriate).
Note that this conversion is only performed by the static service wrappers likeClient.chart.default_options(), and not for the dynamic invocation method:Client.call('Chart', 'defaultOptions').Naming ConventionsThe python names for services, functions, and input parameters are identical to those in the officialNetsBlox documentation, except that they are converted into snake case to by more pythonic.
Of course, any modern editor will have some form of intellisense built in, so in practice this is a non-issue.