Open Python code in new tab without saving in a file

Hell there,

I’m trying to do something relatively simple but I’m not sure it’s actually possible.

I’m trying to open a new Python document from my extension. Here is my current code:

// Create a new untitled python file
const file = await this.commands.execute(‘docmanager:new-untitled’, { path: ‘/’, type: ‘file’, ext: ‘.py’ });
// Open the newly created python file
const doc = await this.commands.execute(‘docmanager:open’, { path: file.path });
// Set the generated code into the file

What I would like to achieve instead is to open a new tab with the Python code in the editor, without creating the file and saving it first in order to let the user decide if they want to save it or not. Would that be possible?