> On Feb 7, 12:20 pm, "Sébastien Vincent" free.fr>
> wrote:
> > I've found some class on the Net which takes basically this form :
> >
> > ##
> > class Foo:
> > def __init__(self):
> > self.tasks = []
> >...
> >
> > def method1(self):
> > tasks = []
> > w
Thank you, that's very clear indeed.
"Helmut Jarausch" <[EMAIL PROTECTED]> a écrit dans le message de
news: [EMAIL PROTECTED]
> Sébastien Vincent > I've found some class on the Net which takes basically this form :
>>
>> ##
>> class Foo:
>> def __init__(self):
>> self.tasks = []
Sébastien Vincent I've found some class on the Net which takes basically this form :
>
> ##
> class Foo:
> def __init__(self):
> self.tasks = []
>...
>
> def method1(self):
> tasks = []
> while True:
> ...
> append/pop elements into/from tasks
> ...
Tim Chase wrote:
self.tasks[:] = tasks
What I do not fully understand is the line "self.tasks[:] = tasks". Why
does
the guy who coded this did not write it as "self.tasks = tasks"? What is
the
use of the "[:]" trick ?
>>> It changes the list in-place. If i
On Feb 7, 2008, at 3:19 PM, James Turk wrote:
> if you do
> a = [1,2,3]
> b = []
> b = a
>
> then assign: b[1] = 9
> now a[1] == 9 as well
>
> with a[:] = b you are actually getting a copy of the list rather than
> an alias
Of course, this only works if 'b' is already a list. A more comm
>>> self.tasks[:] = tasks
>>>
>>> What I do not fully understand is the line "self.tasks[:] = tasks". Why
>>> does
>>> the guy who coded this did not write it as "self.tasks = tasks"? What is
>>> the
>>> use of the "[:]" trick ?
>>
>> It changes the list in-place. If it has been given to ot
On 7 fév, 22:16, Steve Holden <[EMAIL PROTECTED]> wrote:
> Diez B. Roggisch wrote:
> >> self.tasks[:] = tasks
>
> >> What I do not fully understand is the line "self.tasks[:] = tasks". Why
> >> does
> >> the guy who coded this did not write it as "self.tasks = tasks"? What is
> >> the
> >> u
Steve Holden ha scritto:
>>> What I do not fully understand is the line "self.tasks[:] = tasks".
>>> Why does the guy who coded this did not write it as "self.tasks =
>>> tasks"? What is the use of the "[:]" trick ?
>>
>> It changes the list in-place. If it has been given to other objects,
>> i
On Feb 7, 12:20 pm, "Sébastien Vincent" free.fr>
wrote:
> I've found some class on the Net which takes basically this form :
>
> ##
> class Foo:
> def __init__(self):
> self.tasks = []
>...
>
> def method1(self):
> tasks = []
> while True:
> ...
> append
Diez B. Roggisch wrote:
> "S����������������������������������������������" schrieb:
>> I've found some class on the Net which takes basically this form :
>>
>> ##
>> class Foo:
>> def __init__(self)
"S����������������������������������������������" schrieb:
> I've found some class on the Net which takes basically this form :
>
> ##
> class Foo:
> def __init__(self):
> self.tasks = []
>
I've found some class on the Net which takes basically this form :
##
class Foo:
def __init__(self):
self.tasks = []
...
def method1(self):
tasks = []
while True:
...
append/pop elements into/from tasks
...
if condition : break
self.tasks[:] = t
12 matches
Mail list logo