简体   繁体   中英

functions within functions and calling main() using python

I have several functions such as

def plot_lines(...):

def plot_setup():

def BP4_avg(...):

which all work fine but when I add a calling function main() it breaks

def main():
    ...

    plot_setup()

    BP4_avg(...)

    plt.show()


if __name__ == "__main__":
    main()

Any ideas?

If I remove main() and just have

plot_setup()

BP4_avg(...)

plt.show()

program works.

Thanks

In the first version you're just defining the functions but you are not calling them - so everything works fine.

On the second version (the one with main() ) you are actually executing these functions and one of them breaks...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM