AutoHotkey Community

It is currently May 27th, 2012, 5:07 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: How to learn Python?
PostPosted: May 4th, 2010, 10:03 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
During the past few years, I've made a few feeble attempts at learning Python. It sounds like a powerful, versatile and popular programming language. I've never gotten past the introduction though and during my last attempt none of the example code I found on the net worked properly, they all gave syntax errors which I couldn't debug. Has anyone else by any chance had similar experiences?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2010, 11:55 am 
why python?

why not C\C++?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2010, 12:31 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
No particular reason really. I'd love to learn C and C++ as well, but I need to start somewhere.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2010, 7:55 pm 
Offline

Joined: March 19th, 2006, 5:52 am
Posts: 419
My answer is the same for any language. Think of some program/project that you want to use. After you have run thru the basic tutorials, just start coding. When you get to a point when you don't know how to do something, google it and then ask a forum if you still don't have an answer.

Tutorials and sample problems are ok, but unless you are really interested, it is hard to care much about what you are doing.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2010, 10:08 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
TheIrishThug: My approach is just as you describe it. My last attempt never made it past the first script. I couldn't get a single script to run without errors. I was just frustrated and thought perhaps I wasn't the only one. I suppose I'll give it another go sometime and if I still can't get even the simplest of scripts/programs to work, I'll find a more suitable forum to vent my frustration. Thanks for listening!

I completely agree that it's difficult to care to learn without a specific goal in mind.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 2:15 pm 
Offline

Joined: April 18th, 2010, 11:33 am
Posts: 159
Anyway Murp|e,

You can navigate to this page,
http://gigapedia.info/1/python

where you will find free ebooks on python language

but to download them you will need to register and login at gigapedia.com

you can find hundreds of them, totally free!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 2:30 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
Thanks CyberGeek, that looks like a nice resource indeed!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 11:07 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
C++ Guru:
Learning Python by Mark Lutz wrote:
Python boosts developer productivity many times beyond compiled or statically typed languages such as C, C++, and Java. Python code is typically one-third to one-fifth the size of equivalent C++ or Java code. That means there is less to type, less to debug, and less to maintain after the fact. Python programs also run immediately, without the lengthy compile and link steps of some other tools, further boosting programmer speed


I am certain C/C++ has many advantages, but the above sounds like a very good reason to learn Python. I'm about to try a few examples from the book (Like Hello World) and hopefully they will run without problems....


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2010, 11:58 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
If anyone else ever reads this thread and has similar problems. My problem was due to the fact that all of the examples I happened to have found online and in books were based on version 2 of Python whereas I had downloaded and installed the latest version 3, which is evidently quite different. E.g. print 'hello world' did not work on version 3, after installing version 2.6.5 everything seems to work as expected.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2010, 8:32 pm 
Offline

Joined: March 19th, 2006, 5:52 am
Posts: 419
Yeah, Python3 is still pretty fresh and hasn't been fully adopted. The project I'm doing at work is all Python2. I would expect the error message for print would be clear enough that it would be obvious that it is now a function. With that issue solved, hopefully you get farther along the road.

As far as the comment about C++/Java vs Python. I would say that a lot of that comes from the fact that those languages are strongly typed and Python is not. Similar to AHK, a function is only validated to have the correct number of arguments. If you use the function incorrectly, you can't be told that when you try to run it. Where as Java will tell me while I'm coding that I tried to pass object A when the function expects object B. And if that path doesn't always get executed, you might not know about bugs in your code for a while.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2010, 8:36 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
A friend of mine who had to learn Python for some research
told me that some tutorials got mistaken implementations.

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 7th, 2010, 8:57 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
TheIrishThug: IRC solved the problem for me, not the error message. I hadn't thought about the fact that Java and the likes are less prone to error due to their strongly typed nature. The quote says python is typically much short than C code. A simply GUI with an ok and cancel button was one third the length in AHK than in Python though, if that means anything.


Last edited by Murp|e on May 8th, 2010, 2:48 pm, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2010, 7:49 am 
Offline

Joined: April 18th, 2010, 11:33 am
Posts: 159
Hello World! Example Comparison

In Python
Code:
print “Hello World!”


In C
Code:
#include<stdio.h>

main()
{
    printf("Hello World");
}


In C++
Code:
#include <iostream>
using namespace std;
void main()
{
  cout << "Hello World!" << endl;   cout << "Welcome to C++ Programming" << endl; }

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2010, 7:51 am 
Offline

Joined: April 18th, 2010, 11:33 am
Posts: 159
Check out http://groups.engin.umd.umich.edu/CIS/course.des/cis400/index.html

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 8th, 2010, 2:51 pm 
Offline

Joined: January 12th, 2007, 4:30 am
Posts: 531
Location: Norway
In Cobol:

Quote:
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLOWORLD.
000300
000400*
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
000900
001000 DATA DIVISION.
001100 FILE SECTION.
001200
100000 PROCEDURE DIVISION.
100100
100200 MAIN-LOGIC SECTION.
100300 BEGIN.
100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
100500 DISPLAY "Hello world!" LINE 15 POSITION 10.
100600 STOP RUN.
100700 MAIN-LOGIC-EXIT.
100800 EXIT.


(http://groups.engin.umd.umich.edu/CIS/c ... world.html)

I checked the area of application for Cobol and it says "COBOL is ideally suited for the solution of business problems. For example, if a company wanted to keep track of its employees’ annual wages, COBOL would be ideal language for implementation". That sounds fairly odd to me. It sounds like something a database would be well suited to handle, not a programming language.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 22 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: 0x150||ISO, Yahoo [Bot] and 3 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group