How to make __name__ return "__main__" in exec

19 views
Skip to first unread message

Carlo Oliveira

unread,
Aug 1, 2015, 4:08:35 PM8/1/15
to 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

unread,
Aug 1, 2015, 5:39:37 PM8/1/15
to 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:
Reply all
Reply to author
Forward
0 new messages