[Idle-dev] Is this a bug

Weeble clockworksaint at gmail.com
Wed May 20 14:50:38 CEST 2009


It doesn't *look* like a bug, nor does it seem to be related to IDLE -
the results are just the same when you run it directly from the
command-line. What were you expecting to happen? You are creating an
empty list, then repeatedly using slice assignment to replacing its
tail. Did you intend to use slice assignment? "v[me:]" is slice
notation for "the part of the list beginning at element index me and
continuing to the end of the list". I would guess that perhaps you
meant:

a=10
x=0
y=0
z=0

v=[]
for me in range(a):
        x=x+2
        y=y+4
        z=z+6
        v.append((x, y, z))
        print v[me]
for e in range(a):
        print v[e]

or even

a=10
x=0
y=0
z=0

v={}
for me in range(a):
        x=x+2
        y=y+4
        z=z+6
        v[me] = x, y, z
        print v[me]
for e in range(a):
        print v[e]

Your question is not really suited to idle-dev, which is about
development of the IDLE editor for Python. You will likely get much
better answers next time if you try the python-help mailing list or a
newsgroup like comp.lang.python.

On Tue, May 19, 2009 at 12:59 AM, VIC BURAZIN <vic_2007_ at hotmail.com> wrote:
> idle-dev at python.org
>
> a=10
> x=0
> y=0
> z=0
>
> v=[]
> for me in range(a):
>         x=x+2
>         y=y+4
>         z=z+6
>         v[me:] = x, y, z
>         print v[me:]
> for e in range(a):
>         print v[e:]
>
> IDLE 1.2.2      ==== No Subprocess ====
>>>>
> [2, 4, 6]
> [4, 8, 12]
> [6, 12, 18]
> [8, 16, 24]
> [10, 20, 30]
> [12, 24, 36]
> [14, 28, 42]
> [16, 32, 48]
> [18, 36, 54]
> [20, 40, 60]
> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 60]
> [4, 6, 8, 10, 12, 14, 16, 18, 20, 40, 60]
> [6, 8, 10, 12, 14, 16, 18, 20, 40, 60]
> [8, 10, 12, 14, 16, 18, 20, 40, 60]
> [10, 12, 14, 16, 18, 20, 40, 60]
> [12, 14, 16, 18, 20, 40, 60]
> [14, 16, 18, 20, 40, 60]
> [16, 18, 20, 40, 60]
> [18, 20, 40, 60]
> [20, 40, 60]
>>>>
>
>
> ________________________________
> Create a cool, new character for your Windows Live™ Messenger. Check it out
> _______________________________________________
> IDLE-dev mailing list
> IDLE-dev at python.org
> http://mail.python.org/mailman/listinfo/idle-dev
>
>


More information about the IDLE-dev mailing list