how to mimik a main() function to start a program with entry point?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • krishnakant Mane

    #1

    how to mimik a main() function to start a program with entry point?

    hello all.
    I have one simple query and may be that's to stupid to answer but I am
    not finding the answer any ways.
    I have a set of modules in my package and out if which one is my
    actual starting point to my entire program. say for example I have an
    entire database application ready and I want a main (as in java or c)
    to initiate the program and may be bring up a login screen and then
    pass the control on to the main window.
    if I am giving raw source code that is easy because I will tell user
    to run the command ./xyz.py which has that function.
    but if I freze it into an executable with py2exe for example , how do
    I solve this problem?
    thanks.
    Krishnakant.
  • sturlamolden

    #2
    Re: how to mimik a main() function to start a program with entry point?


    krishnakant Mane wrote:
    I have a set of modules in my package and out if which one is my
    actual starting point to my entire program. say for example I have an
    entire database application ready and I want a main (as in java or c)
    to initiate the program and may be bring up a login screen and then
    pass the control on to the main window.
    if I am giving raw source code that is easy because I will tell user
    to run the command ./xyz.py which has that function.
    but if I freze it into an executable with py2exe for example , how do
    I solve this problem?

    If you cannot figure that out, you should not selling software.

    if __name__ == '__main__':
    #whatever

    Comment

    • kmsmgill@gmail.com

      #3
      Re: how to mimik a main() function to start a program with entry point?

      def main():
      print "Hello"

      if __name__ == "__main__":
      main()

      Simply verify __name__ and run any function from there. This will cause
      main() to be run if the script is run directly. I haven't used py2exe,
      so I'm not sure if it still applies.

      --Kevin




      krishnakant Mane wrote:
      hello all.
      I have one simple query and may be that's to stupid to answer but I am
      not finding the answer any ways.
      I have a set of modules in my package and out if which one is my
      actual starting point to my entire program. say for example I have an
      entire database application ready and I want a main (as in java or c)
      to initiate the program and may be bring up a login screen and then
      pass the control on to the main window.
      if I am giving raw source code that is easy because I will tell user
      to run the command ./xyz.py which has that function.
      but if I freze it into an executable with py2exe for example , how do
      I solve this problem?
      thanks.
      Krishnakant.

      Comment

      • Joshua J. Kugler

        #4
        Re: how to mimik a main() function to start a program with entry point?

        krishnakant Mane wrote:
        hello all.
        I have one simple query and may be that's to stupid to answer but I am
        not finding the answer any ways.
        I have a set of modules in my package and out if which one is my
        actual starting point to my entire program. say for example I have an
        entire database application ready and I want a main (as in java or c)
        to initiate the program and may be bring up a login screen and then
        pass the control on to the main window.
        if I am giving raw source code that is easy because I will tell user
        to run the command ./xyz.py which has that function.
        but if I freze it into an executable with py2exe for example , how do
        I solve this problem?
        thanks.
        Krishnakant.
        See http://www.artima.com/weblogs/viewpost.jsp?thread=4829
        by GvR himself.

        j

        --
        Joshua Kugler
        Lead System Admin -- Senior Programmer

        PGP Key: http://pgp.mit.edu/  ID 0xDB26D7CE

        --
        Posted via a free Usenet account from http://www.teranews.com

        Comment

        Working...