Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 403505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T17:13:22+00:00 2026-05-12T17:13:22+00:00

I have a background in C++ and Java and Objective C programming, but i

  • 0

I have a background in C++ and Java and Objective C programming, but i am finding it hard to learn python, basically where its “Main Function” or from where the program start executing. So is there any tutorial/book which can teach python to people who have background in C++ or Java. Basically something which can show if how you were doing this in C++ and how this is done in Python.

OK i think i did not put the question heading or question right, basically i was confused about the “Main” Function, otherwise other things are quite obvious from python official documentation except this concept.

Thanks to all

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T17:13:23+00:00Added an answer on May 12, 2026 at 5:13 pm

    When you run a script through the Python interpreter (or import that script from another script), it actually executes all the code from beginning to end — in that sense, there is no “entry point” to a Python script.

    So to work around this, Python automatically creates a __name__ variable and fills it with the value "__main__" when you are running a script by itself (as opposed to something else importing that script). That’s why you’ll see many scripts like:

    def foo():
        print "Hello!"
    
    if __name__ == "__main__":
       foo()
    

    where all the function/class definitions are at the top, and there is a similar if-statement as the last thing in the script. You are guaranteed that Python will start executing the script from top-to-bottom, so it will read all of your definitions there. If you wanted, you could intermingle actual functional code inside all the function definitions.

    If this script was named bar.py, you could do python bar.py at the command line and you would see the script print out "Hello!".

    On the other hand, if you did import bar from another Python script, nothing would print out until you did bar.foo(), because __name__ was no longer "__main__" and the if-statement failed, thus foo was never executed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 211k
  • Answers 211k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer header is an implicit object in JSPs that maps to… May 12, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer The naive way to do this would just be to… May 12, 2026 at 10:12 pm
  • Editorial Team
    Editorial Team added an answer You might get some help from yacc -d, which produces… May 12, 2026 at 10:12 pm

Related Questions

I am newbie and finding it very hard to grasp the syntax of Class
I have a background of programming in Java and C++, so I know all
I've been parsing poker hand histories for the past year and have learned quite
I'm currently working on a project that has scope to become quite large, however

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.