had a request for what this would look like using pymel:
import pymel.core as pm
import sys
def main( argv = None ):
print "Hello world!"
if __name__ == "__main__":
main()
honestly, i have no idea why that example uses MGlobal.executeCommand. by default print goes to sys.stdout. in gui mode sys.stdout goes to the script editor and you must use sys.__stdout__ to write to the console/shell/terminal, but in batch mode everything goes to the shell.
also, if you're on linux or osx you can add this to the top of your file:
#!/usr/bin/env mayapy
then:
chmod 777 myfile.py
as long as mayapy is on the PATH you can now execute your script directly like this:
./myfile.py
instead of like this:
mayapy mayfile.py
-chad
-chad