-
Notifications
You must be signed in to change notification settings - Fork 422
Description
Is your feature request related to a problem? Please describe.
I would like to execute a notebook with different values (such as different values for a path), but also with a default value. The current problem is due to a lack of an official way to have parameters when importing a notebook, as we rely on variables already defined to transfer information.
I'm giving a full example to explain.
Here is the content of a notebook with a defined value:
string path = "C:";
Console.WriteLine(path);
When I call it, the path always has the same value.
#!import notebook.dib
C:
So I edit this notebook to remove the variable definition.
Console.WriteLine(path);
When I call it, the path has the value defined before importing the notebook.
string path = "C:";
#!import notebook.dib
C:
But now, the imported notebook is no longer working by itself. Trying to execute it directly outputs an error.
Error: (1,1): error CS0103: The name 'path' does not exist in the current context
Describe the solution you'd like
The easiest way to use would be to allow something like #!import notebook.dib arg0 arg1, and access args[] in the imported notebook. It's a common solution.
Describe alternatives you've considered
Writing a file on disk before importing the notebook, and the imported notebook reads the value in the file or gives the variable a default value.
I tried various ways, such as accessing variables from #!who, looking into #!share, etc. dotnet-repl allows to fill @input.
Some languages other than C# allow to check if a variable is defined, but I don't think it's the direction to follow.