Ok... I know pretty much how .extend works on a list... basically it
just tacks the second list to the first list... like so:
lista=[1]
listb=[2,3]
lista.extend(listb)
print lista;
[1, 2, 3]
what I'm confused on is why this returns None:
lista=[1]
listb=[2,3]
print lista.extend(listb)
J a écrit :
Ok... I know pretty much how .extend works on a list... basically it
just tacks the second list to the first list... like so:
lista=[1]
listb=[2,3]
lista.extend(listb)
print lista;
[1, 2, 3]
what I'm confused on is why this returns None:
So why the None? Is this because what's
On 04/16/10 23:41, J wrote:
Ok... I know pretty much how .extend works on a list... basically it
just tacks the second list to the first list... like so:
lista=[1]
listb=[2,3]
lista.extend(listb)
print lista;
[1, 2, 3]
what I'm confused on is why this returns None:
lista=[1]
On Sat, 2010-04-17 at 00:37 +1000, Lie Ryan wrote:
On 04/16/10 23:41, J wrote:
So, what I'm curious about, is there a list comprehension or other
means to reduce that to a single line?
from itertools import chain
def printout(*info):
print '\n'.join(map(str, chain(*info)))
or
On 4/16/2010 9:41 AM, J wrote:
Ok... I know pretty much how .extend works on a list... basically it
just tacks the second list to the first list... like so:
lista=[1]
listb=[2,3]
lista.extend(listb)
print lista;
[1, 2, 3]
This shows right here that lista is extended in place. If you are not
On Fri, Apr 16, 2010 at 15:16, Terry Reedy tjre...@udel.edu wrote:
On 4/16/2010 9:41 AM, J wrote:
Ok... I know pretty much how .extend works on a list... basically it
just tacks the second list to the first list... like so:
lista=[1]
listb=[2,3]
lista.extend(listb)
print lista;
[1, 2,
Stef Mientki a écrit :
hello,
I basically need a list with a few extra attributes,
so I derived a new object from a list, and it works perfect.
But I wonder why the newly derived list component is much more flexible ?
# so here is the new list object
class tGrid_List ( list ) :
pep08: class
thanks guys,
def __init__ ( self, value = [] ) :
Gotcha : default argument values are eval'd only once. Also, it would
make more sense IMHO to follow the parent's class initializer's
behaviour:
def __init__(self, *args)
list.__init__ ( self, value )
thanks guys,
def __init__ ( self, value = [] ) :
Gotcha : default argument values are eval'd only once. Also, it would
make more sense IMHO to follow the parent's class initializer's
behaviour:
def __init__(self, *args)
list.__init__ ( self, value )
On 30 juin, 21:05, Stef Mientki [EMAIL PROTECTED] wrote:
thanks guys,
def __init__ ( self, value = [] ) :
Gotcha : default argument values are eval'd only once. Also, it would
make more sense IMHO to follow the parent's class initializer's
behaviour:
Ah hem Sorry, should have
hello,
I basically need a list with a few extra attributes,
so I derived a new object from a list, and it works perfect.
But I wonder why the newly derived list component is much more flexible ?
# so here is the new list object
class tGrid_List ( list ) :
def __init__ ( self, value = [] ) :
Stef Mientki wrote:
... (approximately, I PEP-8'ed it a bit) ...
class tGrid_List(list):
def __init__(self, value=[]):
list.__init__(self, value)
# and with this new list component, I can add new attributes on the fly
a = tGrid_list([2, 3])
a.New_Attribute = 'some text'
# I'm not
12 matches
Mail list logo