Toolkits > com.ibm.streamsx.topology 2.1.0 > com.ibm.streamsx.topology.python > Python Topology API
Develop IBM Streams applications with Python.
A functional api to develop streaming applications for IBM Streams using Python. Streams are defined, transformed and sinked (terminated) using Python callables. The return of a callable determines the content of the stream. Tuples on a stream are Python objects or structured SPL tuples, object streams may contain different types of objects.
Example code that builds and then submits a Hello World topology.
import mymodule from streamsx.topology.topology import * import streamsx.topology.context topo = Topology("HelloWorld") hw = topo.source(['hello', 'world', 2018]) hw.for_each(print) streamsx.topology.context.submit("STANDALONE", topo.graph)
The source function is passed a callable that returns an Iterable or an Iterable, in a list of two strings and a number.
SPL runtime will create an iterator from source's iterable. Then each value returned from the iterator will be sent on the stream.
The for_each function is passed a callable that will be called for each tuple on the stream, in this case the builtin print function (Python 3).
Python applications can publish streams and subscribe to streams from other applications running in the same IBM Streams instance. These allows interchange of streaming data from applications implemented in any language supported by IBM Streams.
See namespace:com.ibm.streamsx.topology.topic for more details.