LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-10-2005, 12:39 PM   #1
diz12
Member
 
Registered: Jun 2005
Posts: 50

Rep: Reputation: 15
Python Questions ... any gurus here?


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
 
Old 06-10-2005, 01:38 PM   #2
deiussum
Member
 
Registered: Aug 2003
Location: Santa Clara, CA
Distribution: Slackware
Posts: 895

Rep: Reputation: 32
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.
 
Old 06-10-2005, 01:47 PM   #3
diz12
Member
 
Registered: Jun 2005
Posts: 50

Original Poster
Rep: Reputation: 15
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
 
Old 06-10-2005, 02:50 PM   #4
cb951303
Member
 
Registered: Jan 2004
Distribution: Slackware 11 + Dropline Gnome 2.16
Posts: 194

Rep: Reputation: 30
I've just started to learn python, and I loved it, it's really very easy and practical.after c/c++, my coding speed doubled
 
Old 06-10-2005, 03:22 PM   #5
diz12
Member
 
Registered: Jun 2005
Posts: 50

Original Poster
Rep: Reputation: 15
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.
 
Old 06-10-2005, 04:11 PM   #6
cb951303
Member
 
Registered: Jan 2004
Distribution: Slackware 11 + Dropline Gnome 2.16
Posts: 194

Rep: Reputation: 30
Quote:
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.
I agree
 
Old 06-10-2005, 04:14 PM   #7
needforspeed
Member
 
Registered: Aug 2003
Distribution: Gentoo
Posts: 73

Rep: Reputation: 15
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.
 
Old 06-11-2005, 04:42 AM   #8
llama_meme
Member
 
Registered: Nov 2001
Location: London, England
Distribution: Gentoo, FreeBSD
Posts: 590

Rep: Reputation: 30
The usual idiom is

Code:
if __name__ == '__main__':
  # Run the main program
 
Old 06-11-2005, 06:54 AM   #9
kapsikum
Member
 
Registered: Mar 2005
Location: INDIA
Posts: 79

Rep: Reputation: 16
hi,

just visit this page and all ur initial doubts will be gone!

http://www-106.ibm.com/developerwork...y/l-pyint.html
 
Old 06-11-2005, 01:16 PM   #10
diz12
Member
 
Registered: Jun 2005
Posts: 50

Original Poster
Rep: Reputation: 15
thanks guys!! big help , makes the picture come together

...nice site kapsikum! thanks

Last edited by diz12; 06-11-2005 at 01:20 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python / Tkinter : 2 quick questions infidel Programming 0 12-31-2004 04:19 PM
Some questions on integrating a couple simple python programs. RHLinuxGUY Programming 1 12-17-2004 12:32 PM
Considering Python and have a few questions prophet621 Programming 21 09-10-2004 07:06 AM
Two python questions squirreldogger Programming 0 01-06-2004 04:23 PM
some basic questions for you gurus !! shanlz Linux - General 1 02-25-2003 02:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration