Help With map() *He says while pulling his hair out*
fgeiger at datec.at
Mon Jul 9 08:14:55 CEST 2001
This works for me:
>>> import string
['1', '2', '3']
>>> map(string.atoi, _)
[1, 2, 3]
s is a string. split splits the strings, where the '.' is the delimiter,
i.e. those are the spots, where the string is cut (the delim's are
The result is a list of strings.
map applies string.atoi to all the members of the list. The result is a list
"EricIDLE" <grayson-wilson at home.com> wrote in message
news:pM927.657463$166.13605776 at news1.rdc1.bc.home.com...
> Ok first off I have a wee problem with one of the examples in my book it
> as follows:
> ls = string.split(s, '.')
> md = map(string.atoi, ls)
> Ok. well the problem is basically the whole thing. I know s="22.214.171.124.12"
> is just defining the varible 's' with the numbers. But my first problem is
> after string.split in its argument I know what the S means but I dont know
> what the '.' means does that mean to remove all the periods?
> The second problem is that I dont quite grasp the map() function what
> exactly does it do, In its argument it says in lamens terms "Turn the
> ls into intergers" my problems is wasent it always intergers? I mean the
> varible ls contains ['12', '19', '6', '7', '12'] arent those intergers
> are numbers. Any ways if you could reply answering all the questions in
> whole or maybe just a few of em' it would be great.
More information about the Python-list