How to make __name__ return "__main__" in exec

已查看 19 次
跳至第一个未读帖子

Carlo Oliveira

未读,
2015年8月1日 16:08:352015/8/1
收件人 brython
Older versions of on line Brython would return "__main__" for __name__. Now they return exec_[number].

I want to use ace editor to teach python to my students to use the famous boilerplate:
 if __name__ == "__main__":
    main()

Currently I have to teach a weird variation:

 if "exec_" in __name__:
    main()

That is not compatible with Desktop Python and they have to change their code to run in Cpython.

How can a tune exec as to make __name__ = "__main__"?

This will help them to produce modules that can be tested as stand_alone but remain unchanged when tied together as a large program.


Olemis Lang

未读,
2015年8月1日 17:39:372015/8/1
收件人 bry...@googlegroups.com
Please , create a ticket . Thanks for the report .
> --
> You received this message because you are subscribed to the Google Groups
> "brython" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to brython+u...@googlegroups.com.
> To post to this group, send email to bry...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/brython/0818a666-3295-4e64-a2c5-624a8abad0d0%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>


--
Regards,

Olemis - @olemislc

Apache™ Bloodhound contributor
http://issues.apache.org/bloodhound
http://blood-hound.net

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:
回复全部
回复作者
转发
0 个新帖子