[issue40433] Equality operations between lists and arrays

2020-05-01 Thread Raymond Hettinger
Raymond Hettinger added the comment: I concur with Terry that this would need to be taken to python-ideas. -- resolution: -> rejected stage: -> resolved status: open -> closed ___ Python tracker

[issue40433] Equality operations between lists and arrays

2020-05-01 Thread Terry J. Reedy
Terry J. Reedy added the comment: This is not clearly a good idea. Lists and tuples with same contents do not compare equal, although set and frozenset do. I suggest that you post this idea to python-ideas list. -- nosy: +rhettinger, terry.reedy versions: -Python 3.5, Python 3.6,

[issue40433] Equality operations between lists and arrays

2020-04-28 Thread Ahmed Amr
, along with that, arrays compare to each other correctly, and lists compare to each other correctly. based on that, switching some lists to arrays in a python codebase may break some equality conditions within that code between lists and arrays -- files

Re: Lists and arrays

2013-04-23 Thread 88888 Dihedral
Ana Dionísio於 2013年4月23日星期二UTC+8上午2時13分38秒寫道: Hello! I need your help! I have an array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] list=array[0]+ array[3]+ array[4] list: [a,1,2] When I do it like

Re: Lists and arrays

2013-04-23 Thread Denis McMahon
On Mon, 22 Apr 2013 11:13:38 -0700, Ana Dionísio wrote: I have an array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] list=array[0]+ array[3]+ array[4] list: [a,1,2] When I do it like this: list=array[0]+ array[3]+ array[4] I get

Lists and arrays

2013-04-22 Thread Ana Dionísio
Hello! I need your help! I have an array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] list=array[0]+ array[3]+ array[4] list: [a,1,2] When I do it like this: list=array[0]+ array[3]+ array[4] I get an error: TypeError: unsupported

Re: Lists and arrays

2013-04-22 Thread Dave Angel
On 04/22/2013 02:13 PM, Ana Dionísio wrote: Hello! I need your help! I have an array I think you mean you have a numpy array, which is very different than a python array.array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] That's a

Re: Lists and arrays

2013-04-22 Thread BartC
Ana Dionísio anadionisio...@gmail.com wrote in message news:de1cc79e-cbf7-4b0b-ae8e-18841a1ef...@googlegroups.com... Hello! I need your help! I have an array and I need pick some data from that array and put it in a list, for example: array= [a,b,c,1,2,3] list=array[0]+ array[3]+

Re: [long] nested lists as arrays

2005-02-20 Thread [EMAIL PROTECTED]
great thanks -- http://mail.python.org/mailman/listinfo/python-list

Problem with nested lists as arrays

2005-02-14 Thread benjamin . cordes
Hello, For a class modeling the block puzzle I use nested lists as arrays. Within this class there is a method for swaping elements. I have lots of trouble with that method but can't figure it out. It has probably to do with my unuseful approach to nested lists, but I don't want to write the code

Re: Problem with nested lists as arrays

2005-02-14 Thread Diez B. Roggisch
Some general remarks: def getEmptySlot(self): i = 0 j = 0 while i = self.dim-1: while j = self.dim-1: if self.elements[j][i] == -1: return [j, i] j = j+1 j = 0 i = i + 1

Re: nested lists as arrays

2005-02-14 Thread Diez B. Roggisch
[EMAIL PROTECTED] wrote: Hi, why can't I do this: dummy = self.elements[toy][tox] self.elements[toy][tox] = self.elements[fromy][fromx] self.elements[fromy][fromx] = dummy after initialising my nested list like this: self.elements = [[0 for column

Re: nested lists as arrays

2005-02-14 Thread bruno modulix
[EMAIL PROTECTED] wrote: Hi, why can't I do this: dummy = self.elements[toy][tox] self.elements[toy][tox] = self.elements[fromy][fromx] self.elements[fromy][fromx] = dummy after initialising my nested list like this: self.elements = [[0 for column in range(dim)] for

nested lists as arrays

2005-02-14 Thread naturalborncyborg
Hi, I'm using nested lists as arrays and having some problems with that approach. In my puzzle class there is a swapelement method which doesn't work out. Any help and comments on the code will be appreciated. Thanks. # Puzzle.py # class for a sliding block puzzle # an starting state of a 8

Re: nested lists as arrays

2005-02-14 Thread [EMAIL PROTECTED]
Diez B. Roggisch wrote: [EMAIL PROTECTED] wrote: Hi, why can't I do this: dummy = self.elements[toy][tox] self.elements[toy][tox] = self.elements[fromy][fromx] self.elements[fromy][fromx] = dummy after initialising my nested list like this:

Re: nested lists as arrays

2005-02-14 Thread Fredrik Lundh
naturalborncyborg [EMAIL PROTECTED] wrote: Hi, I'm using nested lists as arrays and having some problems with that approach. In my puzzle class there is a swapelement method which doesn't work out. what happens, and what do you expect? Any help and comments on the code will be appreciated

Re: nested lists as arrays

2005-02-14 Thread Michael Spencer
naturalborncyborg wrote: Hi, I'm using nested lists as arrays and having some problems with that approach. In my puzzle class there is a swapelement method which doesn't work out. What doesn't work out? On casual inspection that method seems to work: p = Puzzle(2) p.elements[0][0] = 1

Re: nested lists as arrays

2005-02-14 Thread [EMAIL PROTECTED]
Thanks for the code. What I want to do is this: I want to solve the block puzzle problem. The problem is as follows: You have a nxn Array of Numbers and one empty space. Now you there are up to four possible moves: up, right, down and left, so that each neighbour of the empty slot can be moved

Re: Problem with nested lists as arrays

2005-02-14 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 'Having trouble' is too vague to figure out. However, I would delete this: def getEmptySlot(self): i = 0 j = 0 while i = self.dim-1: while j = self.dim-1: if self.elements[j][i]

Re: nested lists as arrays

2005-02-14 Thread Terry Reedy
Diez B. Roggisch [EMAIL PROTECTED] wrote in message And use xrange instead of range. For small dimensions like 3,4,5, xrange is way overkill and perhaps takes both more space and time. Since dim is a constant for a given puzzle, I would set self._range = range(dim) in __init__() and use

Re: nested lists as arrays

2005-02-14 Thread [EMAIL PROTECTED]
Allright. What difference in runtime and space would it make using dictionaries instead? Do you have a pointer for me concerning runtime of standard manipulations in Pythons? Thanks for tip. -- http://mail.python.org/mailman/listinfo/python-list

Re: nested lists as arrays

2005-02-14 Thread [EMAIL PROTECTED]
Allright. What difference in runtime and space would it make using dictionaries instead? Do you have a pointer for me concerning runtime of standard manipulations in Pythons? Thanks for the tip. -- http://mail.python.org/mailman/listinfo/python-list

Re: nested lists as arrays

2005-02-14 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: Allright. What difference in runtime and space would it make using dictionaries instead? is this for an interactive game? if so, the answer is none at all. (on my machine, you can make about 600 dict[x,y] accesses per second, compared to 750 list[x][y]

Re: nested lists as arrays

2005-02-14 Thread Terry Reedy
[EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] def setRandomState(self): # container for the elements to pick from container = [1,2,3,4,5,6,7,8,-1] # create elements of puzzle randomly i = 0 j = 0 while i = self.dim-1: while j

Re: nested lists as arrays

2005-02-14 Thread Michael Spencer
Terry Reedy wrote: [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] def setRandomState(self): # container for the elements to pick from container = [1,2,3,4,5,6,7,8,-1] # create elements of puzzle randomly i = 0 j = 0 while i = self.dim-1: while

Re: [long] nested lists as arrays

2005-02-14 Thread bruno modulix
[EMAIL PROTECTED] a écrit : Thanks for the code. What I want to do is this: I want to solve the block puzzle problem. The problem is as follows: You have a nxn Array of Numbers and one empty space. Now you there are up to four possible moves: up, right, down and left, so that each neighbour of