Python vs. VBScript vs. JavaScript in context of WindowsScripting Host?

Michael Geary Mike at DeleteThis.Geary.com
Sat May 15 21:38:34 EDT 2004


> John Benson wrote:
> > * no record types, just numerically-indexed arrays, so record
> > handling is kludgy [in VBScript]

Christopher Weimann wrote:
> Scripting.Dictionary
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/jsobjDictionary.asp
>
>    A Dictionary object is the equivalent of a PERL associative array.
>    Items can be any form of data, and are stored in the array. Each
>    item is associated with a unique key. The key is used to retrieve
>    an individual item and is usually an integer or a string, but can
>    be anything except an array.

That's good to know about if you have to live with VBScript. JavaScript has
dictionaries built in (a JavaScript object is a dictionary), so it's easier
to use those instead.

Taking the VBScript example from that page:

Dim d   ' Create a variable.
Set d = CreateObject("Scripting.Dictionary")
d.Add "a", "Athens"   ' Add some keys and items.
d.Add "b", "Belgrade"
d.Add "c", "Cairo"

In JavaScript, you could do:

d = {}
d.a = "Athens"
d.b = "Belgrade"
d.c = "Cairo"

or:

d = { a: "Athens", b: "Belgrade", c: "Cairo" }

-Mike





More information about the Python-list mailing list