Search This Blog

Showing posts with label module. Show all posts
Showing posts with label module. Show all posts

main function in python module



class A:
def __init__(self):
pass


def main():
print("Hello World")


if __name__ == '__main__':
main()

see also

Python: module file name conflicts with the package name

I have a python module file named xml.py, in the module

import xml.etree.ElementTree as ET
... ...
When executing the file, it raises the following error:

ImportError: No module named etree.ElementTree
According the stackoverflow post, it was caused by the moudle file name xml.py, rename the xml.py to something else resolved the issue.