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 efficie
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
--
https://mail.python.org/mailman/l
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 slo
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 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 expecti
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
Diez B. Roggisch 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 _ in x
Bruno Desthuilliers 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':
>
> If you want 6
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
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
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:
>
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], [], [], [], []
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], [], [], [], [], []]
Thank you very much. It was clear.
--
http://mail.python.org/mailman/listinfo/python-list
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 y
[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):
> ...
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
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, 1
18 matches
Mail list logo