runnable Python files

Hey guys,

Just a suggestion, you probably already know this but...  when you have runnable Python files, it's great to use the standard Pythonism for running main code.  For instance, right now in src/python/network/muConsole.py, you have runnable code at the bottom of the file:

class MuConsole:

    ...class implementation here...

mu = MuConsole('')


A standard Pythonism for that is to put the runnable code within an if __name__ == '__main__': block:

if __file__ == '__main__':
    mu = MuConsole ("")

That way, if the file is run directly, the code will be executed, but if the code is imported via an import statement, the code will not be executed and the class can be used.

Just a little sugg.

1 comment

  • 0
    Jon Morley

    Hi Leo,

    I have made this change and others. You should see it in a future release. Thank you for the suggestion.



Please sign in to leave a comment.