Hi all, 2011/1/14 Ilkka Laukkanen <ilkka.s.laukka...@gmail.com>: > Also, the decorator approach is very Python, but to me gives the > impression that there are two main "functions" now, because I've > always though of the "if __name__=='__main__'" bit as being the > semantic equivalent of the C/C++ main().
With the exeception that you don't create a new scope, so everything you have in that block (the True branch of that "if") will bleed out into global scope. Not so if you create a main() function. The reason for "if __name__ == '__main__'" is to allow your script to be imported as module without running any code (that's why for example Python's "zipfile" module works as both a library and as a command-line utility when used as "python -m zipfile"). So it still does make sense to have both the "if __name__" part to avoid running some code when being imported as a module and a separate "main()" function to avoid the local variables in the main function bleed out into global scope. As for the original topic (shortening the QApplication propogue) - it does not really get that much more compact (in terms of lines saved vs. complexity added), and it would make it more difficult (i.e. not straightforward) to "translate" a PySide app to the C++ API of Qt. You could still write a "convenience" module yourself and share it with the list / put it in the PySide Wiki and use it in all your projects - in my opinion, it does not belong in the standard PySide distribution (but maybe there's a place for a "PySide contrib" section?). HTH. Thomas _______________________________________________ PySide mailing list PySide@lists.openbossa.org http://lists.openbossa.org/listinfo/pyside