On Sun, Mar 3, 2019 at 10:12 PM Abdur-Rahmaan Janhangeer
wrote:
>
> i can be wrong but i guess that inserting at the begining does not cause
> troubles as insertion at index 0 is constant (time does not scale with number
> of data)
>
In a deque? Correct. But the price of that is reduced
i can be wrong but i guess that inserting at the begining does not cause
troubles as insertion at index 0 is constant (time does not scale with
number of data)
Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
--
On Sun, Mar 3, 2019 at 6:17 PM Abdur-Rahmaan Janhangeer
wrote:
>
> simple question; why does the normal list not exhibit a deque behaviour
> (left insertion)?
Because it's a lot less efficient. If you want that behaviour, you CAN
still insert into a list at position zero, but it's going to be
simple question; why does the normal list not exhibit a deque behaviour
(left insertion)?
--
Abdur-Rahmaan Janhangeer
http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ
Mauritius
--
https://mail.python.org/mailman/listinfo/python-list
On 2008-05-15, Gabriel [EMAIL PROTECTED] wrote:
Hi all
Just wondering if someone could clarify this behaviour for me, please?
tasks = [[]]*6
tasks
[[], [], [], [], [], []]
tasks[0].append(1)
tasks
[[1], [1], [1], [1], [1], [1]]
Well what I was expecting to end up with was something
Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid writes:
The problem here is that your first statement
# tasks = [[]]*6
creates a list (task) containing 6 references to the *same* (empty) list
object. You can check this easily using the identity test operator 'is':
Gabriel a écrit :
Hi all
Just wondering if someone could clarify this behaviour for me, please?
tasks = [[]]*6
tasks
[[], [], [], [], [], []]
tasks[0].append(1)
tasks
[[1], [1], [1], [1], [1], [1]]
Well what I was expecting to end up with was something like:
tasks
[[1], [], [], [], [],
On 15 Mag, 12:08, Gabriel [EMAIL PROTECTED] wrote:
Hi all
Just wondering if someone could clarify this behaviour for me, please?
tasks = [[]]*6
tasks
[[], [], [], [], [], []] tasks[0].append(1)
tasks
[[1], [1], [1], [1], [1], [1]]
Well what I was expecting to end up with was
Diez B. Roggisch deets at nospam.web.de writes:
So instead of creating a list of list by the *-operator that only multiplies
the references (which is fine immutable objects like strings or numbers),
you need to explicitly create new lists, e.g. with a list-comprehension:
tasks = [[] for _
bockman at virgilio.it writes:
tasks = [ [] for x in xrange(6) ]
tasks[0].append(1)
tasks
[[1], [], [], [], [], []]
Thanks, Bockman
--
http://mail.python.org/mailman/listinfo/python-list
Hi all
Just wondering if someone could clarify this behaviour for me, please?
tasks = [[]]*6
tasks
[[], [], [], [], [], []]
tasks[0].append(1)
tasks
[[1], [1], [1], [1], [1], [1]]
Well what I was expecting to end up with was something like:
tasks
[[1], [], [], [], [], []]
I got this
Gabriel wrote:
Hi all
Just wondering if someone could clarify this behaviour for me, please?
tasks = [[]]*6
tasks
[[], [], [], [], [], []]
tasks[0].append(1)
tasks
[[1], [1], [1], [1], [1], [1]]
Well what I was expecting to end up with was something like:
tasks
[[1], [], [],
On May 15, 5:08 pm, Gabriel [EMAIL PROTECTED] wrote:
Hi all
Just wondering if someone could clarify this behaviour for me, please?
tasks = [[]]*6
tasks
[[], [], [], [], [], []] tasks[0].append(1)
tasks
[[1], [1], [1], [1], [1], [1]]
Well what I was expecting to end up with was
Maybe I'm missing something but the latter is not the behaviour I'm
expecting:
a = [[1,2,3,4], [5,6,7,8]]
b = a[:]
b
[[1, 2, 3, 4], [5, 6, 7, 8]]
a == b
True
a is b
False
for i in range(len(b)):
... for x in range(4):
... b[i][x] = b[i][x] + 10
...
b
[[11, 12, 13, 14], [15, 16,
Am Mittwoch 17 Mai 2006 17:06 schrieb [EMAIL PROTECTED]:
Maybe I'm missing something but the latter is not the behaviour I'm
expecting:
a = [[1,2,3,4], [5,6,7,8]]
b = a[:]
b
[[1, 2, 3, 4], [5, 6, 7, 8]]
a == b
True
a is b
False
Try an:
a[0] is b[0]
and
a[1] is b[1]
[EMAIL PROTECTED] wrote:
Maybe I'm missing something but the latter is not the behaviour I'm
expecting:
a = [[1,2,3,4], [5,6,7,8]]
b = a[:]
b
[[1, 2, 3, 4], [5, 6, 7, 8]]
a == b
True
a is b
False
for i in range(len(b)):
... for x in range(4):
... b[i][x] = b[i][x] + 10
When you did:
b = a[:]
b was then a copy of a, rather than just a reference to the same a.
But what does a contain? It contains two sublists -- that is, it
contains references to two sublists. So b, which is now a copy of a,
contains copies of the two references to the same two sublists.
What
Thank you very much. It was clear.
--
http://mail.python.org/mailman/listinfo/python-list
18 matches
Mail list logo