Reputation: 11
I'm working with two notebooks: one for Q# operations and one for python3 to activate and analyze - both of them are on the same directory.
How can I import a Q# operation (from the IQsharp notebook) into the python one? what is the namespace of IQsharp?
Upvotes: 1
Views: 70
Reputation: 405
The best way is to move your Q# code into a separate .qs file in the same directory as both of your notebooks. The IQ# notebook will automatically compile the .qs file and make the operations available when you load the notebook, and the Python notebook will do the same when you run import qsharp
.
You'll specify your Q# namespace inside the .qs file. Here's an example of what such a .qs file might look like.
Possibly useful tip: From inside an IQ# notebook, you can use the %who
magic command to list all available operations that you've either defined in the notebook or that have been compiled from .qs files. From Python, you can do the same by running print(qsharp.get_available_operations())
.
Upvotes: 1