Re: [Tutor] Slices of lists of lists

2014-03-28 Thread spir
On 03/28/2014 10:42 AM, Jose Amoreira wrote: [...] If we want to access individual rows of this matrix like object, the standard slice notation (on the second index) works as expected also: In [3]: l[0][:] Out[3]: [11, 12, 13] In [4]: l[1][:] Out[4]: [21, 22, 23] Again, fine! No! You *made

Re: [Tutor] Slices of lists of lists

2014-03-28 Thread Jose Amoreira
On 03/28/2014 10:32 AM, Alan Gauld wrote: No, standard slices on the first element will give you sublists of the first row. Python doesn't have any concept of that second dimension, it only sees a list of items. The fact those items are themselves lists is purely incidental to the interpreter.

Re: [Tutor] Slices of lists of lists

2014-03-28 Thread Alan Gauld
On 28/03/14 09:42, Jose Amoreira wrote: Hello! Here is something that surprised me and I still didn't get it. If we want to store a matrix in pure python (no numpy), the first thing that comes to (my) mind is to use a list of lists, like the list l below: In [1]: l=[ ...:[11,12,13],

Re: [Tutor] Slices of lists of lists

2014-03-28 Thread Jose Amoreira
Jose, Just for clarity, are you trying to access a particular *column* in your last example? Bob Yes, that's it! I wanted to say "column", not "row" in my last example. Sorry about that! Thanks Jose ___ Tutor maillist - Tutor@python.org To unsu

Re: [Tutor] Slices of lists of lists

2014-03-28 Thread Bob Williams
On 28/03/14 09:42, Jose Amoreira wrote: > Hello! > Here is something that surprised me and I still didn't get it. > > If we want to store a matrix in pure python (no numpy), the first thing > that comes to (my) mind is to use a list of lists, like the list l below: > In [1]: l=[ >...:[11,1

[Tutor] Slices of lists of lists

2014-03-28 Thread Jose Amoreira
Hello! Here is something that surprised me and I still didn't get it. If we want to store a matrix in pure python (no numpy), the first thing that comes to (my) mind is to use a list of lists, like the list l below: In [1]: l=[ ...:[11,12,13], ...:[21,22,23] ...: ] We can ac

Re: [Tutor] slices

2005-11-17 Thread Will Harris
Blah brain freeze I saw my mistake as I hit send. It should just be word[-2:] So #!/usr/bin/python import sys for word in sys.argv[1:]: print word[-2:] Works now. Thanks! On 11/17/05, Will Harris <[EMAIL PROTECTED]> wrote: Is there an easy way to slice the last set of characters off a

[Tutor] slices

2005-11-17 Thread Will Harris
Is there an easy way to slice the last set of characters off a string when I don't know the length of the string? For example say I have a list of words like    this    though    weather I want to get the last 2 characters from each. But so far nothing I have tried has seeme