ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi I am learning python and I was wondering if anyone could tell me what these are and mean:
Code:
__init__(self)
__main__
basically I don't understand the self either, but I am getting into the classes and reading other peoples codes and I see these alot and self is in green when I am looking at it through ide. and if anyone has msn I would for someone to be there so I could ask for help. Thanks
Dereck
I'm far from a guru, but I believe __init__ is like a constructor function in C++. If you're not familiar with C++ either, than it is basically a function that is called when an object of that type is created. The self is a reference back to the object being created. (A "this" pointer in C++ terminology.)
The __main__ is probably some sort of entry point function that is run with the script is first executed. I don't think any of the few Python scripts I've written have used that before, so I could be way off here.
thanks , I started out with c++ and stopped learning when I finished classes. then I began trying to learn python. I like c++ and will continue learning but, I am not ready to learn c/c++ yet.
thanks again
i was reading somewhere and python is supposed to be 3 - 5 times faster than java and ?- 10 times faster than c++ ... the time it takes to develop a program, not program speed.
Originally posted by diz12 i was reading somewhere and python is supposed to be 3 - 5 times faster than java and ?- 10 times faster than c++ ... the time it takes to develop a program, not program speed.
Python has an excellent reputation for rapid prototyping (ie, fast coding, it's a "glue" language meaning you just kinda glue things together and go). In my software engineering class last semester, my professor wanted everyone to use python and suggested that we use the pygtk widgets. None of us had programmed in python before and it took us only a short while to become used to it.
google for dive into python, there is an online version of the book on the author's site and many people will suggest it. Also, pygtk.org for the gtk widgets provides excellent documentation for using them.
__init__ is a constructor for a class, __main__ is the main class of the program, similar to main() in a c++ program.
Last edited by needforspeed; 06-10-2005 at 04:15 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.