[Tutor] what tools will i need to start my project ?

Alan Gauld alan.gauld at freenet.co.uk
Mon Mar 20 00:21:10 CET 2006


Hi John,

> i'm new to programming and decided to go with python as my first language.

Normally I'd say that was a good choice, but it really depends on what
you want to do.

> my goal is to create an excel macros that will grab information from an 
> html file and import it into my worksheet.

The easiest way to do that is with a VB macro from within Excel.
Therefore you will be better off learning VB for excel. From there
you can fairly easily learn Python if you want to write general purpose
programs too. But for your purpose you will be better off learning VB
IMHO...


> I figure i should first start  apart from excel then work on making it 
> work with it

If you start from inside excel it all becomes much easier.

> possible). is excel macros exclusively vb or is it possible to get excel 
> to work with other languages...

You can use Microsoft COM technology to access Excel from an
external program using almost any language, including Python.

> one, doesn't matter to me. the result will be a listing of all my movies 
> complete with information from imdb.com. i already have something that 
> does this in vb but i didn't write it and i'd like to create my own.

OK, If you want to use this as a way to program in the wider sense
then Python is indeed a better choice.

> i read about find() and how it returns the index of the 1st character of 
> what you searched for. from what i can read from the vb code i have, what 
> i have to do is search for a start and end string and grab the string in 
> between. This works because there is certain formatting/code that stays 
> constant in the html files.

You can use an HTML parser like Beautiful Soup to do all the HTML work,
its much easier to do it that way. HTML is surprisingly hard to parse by 
hand
coding, its much better to use a purpose built library like Beautiful Soup.

> sense? So basically, i am asking what, in addtion to find(), do i need to 
> read up about. I think the vb equiv is InStr() and something else..

You probably should start with an introductory tutorial to cover the
principles of Python. Any of the beginners tutors should cober the basic
string operations.

Since you seem to be a little conversant with VB you might find my tutor
useful since it compares VBScript(VBs little brother) with python.

For this project you only need to cover the "Basics" section.

> how to read from an html using file(). I'm also looking for a searchable 
> directory of python tool usage. for example if i type file() it will give 
> me an explanation of what it does and how to use it.

At the prompt type help:

>>> help(file)

Use Q to quit the help system.

Also Googling for

Python file

and specifying the python.org website in the advanced settings should help.

Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld




More information about the Tutor mailing list