Wow! Thanks for all of the great additional feedback and responses
since I last checked in. The help this group provides is amazing.
I'm glad I found it.
@Andrew -- Thanks for the clarification on the nested for loop and how
to intrepret it. Also, thanks for the information on generators. I
ha
> n = []
> for k in a:
> n.append([int(v) for v in k])
> print n
>
> Does anyone know what I am doing wrong?
>
> Thanks in advance.
>
> Samir
Use extend instead of append:
* Append -> add the one item to the end of the list
* Extend -> add the list of items to the end of the list
--
http://ma
Just to throw my hat in the ring, this is another way you can do this:
[(lambda x : [int(ii) for ii in x])(y) for y in a]
However, I do think dusans way is more elegant.
Best,
R
On Tue, Jul 22, 2008 at 4:58 PM, dusans <[EMAIL PROTECTED]> wrote:
> >>> a = [['1', '2'], ['3'], ['4', '5', '6'], [
>>> a = [['1', '2'], ['3'], ['4', '5', '6'], ['7', '8', '9', '0']]
>>> [map(int, i) for i in a]
[[1, 2], [3], [4, 5, 6], [7, 8, 9, 0]]
On Jul 21, 9:06 pm, Samir <[EMAIL PROTECTED]> wrote:
> Hi Everyone,
>
> I am relatively new to Python so please forgive me for what seems like
> a basic question.
Samir wrote:
For my small list, I didn't notice a
discernible increase in speed, but I may have to try it with a larger
list size.
About speed, and memory consumption:
List comprehensions
(http://docs.python.org/tut/node7.html#SECTION00714) are
just shortcuts for for-loops.
Samir wrote:
On Jul 21, 6:15 pm, Andrew Freeman <[EMAIL PROTECTED]> wrote:
Samir wrote:
On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
Samir wrote:
Hi Everyone,
I am relatively new to Python so please forgive me for what seems like
a basic quest
On Jul 21, 6:15 pm, Andrew Freeman <[EMAIL PROTECTED]> wrote:
> Samir wrote:
> > On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
>
> >> Samir wrote:
>
> >>> Hi Everyone,
>
> >>> I am relatively new to Python so please forgive me for what seems like
> >>> a basic question.
>
> >>> Assume
Samir wrote:
On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
Samir wrote:
Hi Everyone,
I am relatively new to Python so please forgive me for what seems like
a basic question.
Assume that I have a list, a, composed of nested lists with string
representations o
On Jul 21, 4:44 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
> Samir wrote:
> > On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
>
> >> Samir wrote:
>
> >>> Hi Everyone,
>
> >>> I am relatively new to Python so please forgive me for what seems like
> >>> a basic question.
>
> >>> Assume tha
Samir wrote:
On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
Samir wrote:
Hi Everyone,
I am relatively new to Python so please forgive me for what seems like
a basic question.
Assume that I have a list, a, composed of nested lists with string
representations o
On Jul 22, 6:11 am, Samir <[EMAIL PROTECTED]> wrote:
[snip]
> For some reason, the logic I posted seems to work ok while I'm using
> the Python shell, but when used in my code, the program just hangs.
> It never outputs the results. Below is the code in its entirety. Is
> there a problem with my
On Jul 21, 3:20 pm, Gary Herron <[EMAIL PROTECTED]> wrote:
> Samir wrote:
> > Hi Everyone,
>
> > I am relatively new to Python so please forgive me for what seems like
> > a basic question.
>
> > Assume that I have a list, a, composed of nested lists with string
> > representations of integers, suc
Samir wrote:
Hi Everyone,
I am relatively new to Python so please forgive me for what seems like
a basic question.
Assume that I have a list, a, composed of nested lists with string
representations of integers, such that
a = [['1', '2'], ['3'], ['4', '5', '6'], ['7', '8', '9', '0']]
I would l
Hi Everyone,
I am relatively new to Python so please forgive me for what seems like
a basic question.
Assume that I have a list, a, composed of nested lists with string
representations of integers, such that
a = [['1', '2'], ['3'], ['4', '5', '6'], ['7', '8', '9', '0']]
I would like to convert
14 matches
Mail list logo