[issue38808] weird bug while using a for loop and array

2019-11-15 Thread Zach kuunka


Zach kuunka  added the comment:

I will check that out, Thank you

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38808] weird bug while using a for loop and array

2019-11-15 Thread Mark Dickinson


Mark Dickinson  added the comment:

This isn't a bug: it's the way that Python's assignment model works.

This is explained in various places (including the official Python 
documentation), but you may find this excellent presentation by Ned Batchelder 
useful: https://nedbatchelder.com/text/names1.html

--
nosy: +mark.dickinson
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38808] weird bug while using a for loop and array

2019-11-14 Thread Zach kuunka


Zach kuunka  added the comment:

I found out it just happens when you set an array to an array they behave as 
the same thing, which if its not a bug it sure is counter-intuitive. 

if you do
x = 1
then 
y = x
then add one to y you have y = 2 and x = 1
if you do it for an array
arr1 = [1]
then set something equal to that
arr2 = arr1
you essentially have 1 var that act on each other which is odd
so arr2.append(2) or arr1.append(2) make both arr1 and arr2 equal to the same 
thing

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue38808] weird bug while using a for loop and array

2019-11-14 Thread Zach kuunka


New submission from Zach kuunka :

I haven't used this bug reporting thing before so sorry if I mess something up.

Anyway i'm not sure exactly what is causing the issue but the issue appears 
when you have a for loop looping through an array and you make a variable and 
set it to that array and append something to it. If you do the same thing with 
numbers it works as expected but if you do it with an array it for some reason 
doesn't get reset every iteration. Run this and you'll see what i'm talking 
about.

Arr = [1,2,3,4,5]
for num in Arr:
Arr2 = Arr
Arr2.append(1) #the 1 can be anything
print(Arr2)

Also i'm interested to know why this happens, Thank You

--
components: Library (Lib)
files: brokentest.py
messages: 356648
nosy: Zach kuunka
priority: normal
severity: normal
status: open
title: weird bug while using a for loop and array
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file48716/brokentest.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com