@richard , @jwunderl , & other devs: I’m seeking assistance. Second of two threads.
In another thread[1], I was attempting to assist one of our forum members with Python and the project explorer. We can create multi-file projects in JavaScript just fine. Namespaces are possible but not required.
I’m curious on where we are with similar projects in Python.
I can see that some translation helpers have been added to attempt to support namespaces in Python. The following JavaScript code gets translated to the Python code below it by the editor.
// JavaScript version
namespace game1 {
export function start() {
// Do stuff
}
}
# Python version
@namespace
class game1:
def start():
# Do stuff
pass
I cannot quite get the Python namespace bit working, though I suspect it’s a work in progress. No worries. If I simply add Python code to a second file (named, say, game1.py), though, the editor behaves differently from how it behaves with JavaScript.
In JavaScript, you can split code across multiple files and it works just fine. No alterations needed. Functions can be referenced across files without any additional decoration. Code that does not reside within functions runs as if it existed within an on start
container in Blocks … even if that code is spread across multiple files.
In Python, it seems like, even without the @namespace
and class decorations, the editor still creates an “implicit” namespace around code that resides outside of the main.py file. This is IntelliSense kicking in when I try to call the Game1_Start()
function found in the game1.py file in my project.
Are namespaces required in multi-file Python projects? If so, are they ready to use, or are they a work in progress?