On Tuesday, September 9, 2014 11:25:29 AM UTC+5:30, JBB wrote:
> I have a list with a fixed number of elements which I need to grow; ie. add
> rows of a fixed number of elements, some of which will be blank.
> e.g. [['a','b','c','d'], ['A','B','C','D'], ['', 'aa', 'inky', ''], ['',
> 'bb', 'bink
Peter Otten <__peter__ web.de> writes:
[Deletia]
To Peter Otten and Paul Kroeger:
Thank you both, very much. I think I now get why the binding works as it
does in addition to why the list() approach worked.
(Third attempt - priors not going through, please excuse any repetition)
JBB
--
h
Paul Kroeger prz-wugen.com> writes:
>
> Hello,
>
> I'm myself still learning Python, so others may please correct me, if
> I'm wrong.
...
> I hope, the above helps to understand why this behaviour.is to be
> expected.
>
To Peter Otten and Paul Kroeger:
Thank you both, very much. I think I no
Hello,
I'm myself still learning Python, so others may please correct me, if
I'm wrong.
Consider the following sentence of your link "jeffknupp.com/...":
"some_guy and first_names[0] both refer to the same object"
This is what is going on here.
Am Dienstag, den 09.09.2014, 05:50 + schrieb
JBB wrote:
> I have a list with a fixed number of elements which I need to grow; ie.
> add rows of a fixed number of elements, some of which will be blank.
>
> e.g. [['a','b','c','d'], ['A','B','C','D'], ['', 'aa', 'inky', ''], ['',
> 'bb', 'binky', ''], ... ]
>
> This is a reduced representatio
Frank Millman chagford.com> writes:
>
>
> "JBB" gmail.com> wrote in message
> news:loom.20140909T073428-713 post.gmane.org...
> >I have a list with a fixed number of elements which I need to grow; ie. add
> > rows of a fixed number of elements, some of which will be blank.
...
> I am sure th
"JBB" wrote in message
news:loom.20140909t073428-...@post.gmane.org...
>I have a list with a fixed number of elements which I need to grow; ie. add
> rows of a fixed number of elements, some of which will be blank.
>
> e.g. [['a','b','c','d'], ['A','B','C','D'], ['', 'aa', 'inky', ''], ['',
> 'b
I have a list with a fixed number of elements which I need to grow; ie. add
rows of a fixed number of elements, some of which will be blank.
e.g. [['a','b','c','d'], ['A','B','C','D'], ['', 'aa', 'inky', ''], ['',
'bb', 'binky', ''], ... ]
This is a reduced representation of a larger list-of-li
On 7/13/2010 4:22 AM, Gregory Ewing wrote:
John Nagle wrote:
Arguably, if a function just does a "return",
it should be an error to try to use its return value.
It's been suggested at least once before that the
default return value for a function should be some
special value that raises an exc
The better question is, do I ever use them? Thinking back over the code I've
written in the last couple of years, I would say probably two or three times
(mostly in unit tests). I've had to code around string's sequence behavior
DOZENS of times. Is it nifty that strings can be sliced like that?
[Original not available on my swerver, responding here]
>On 7/11/10 10:03 PM, Nathan Rice wrote:
>>
>> Yeah, I long ago filed the in place place in the same folder as
>> strings-as-sequences, all() returning True for an empty iterable and any
>> returning True rather than the thing which triggered
John Nagle wrote:
Arguably, if a function just does a "return",
it should be an error to try to use its return value.
It's been suggested at least once before that the
default return value for a function should be some
special value that raises an exception if you try
to do anything with it exc
On 7/11/2010 5:24 PM, Steven D'Aprano wrote:
On Sun, 11 Jul 2010 08:59:06 -0700, dhruvbird wrote:
Why doesn't python's list append() method return the list itself? For
that matter, even the reverse() and sort() methods? I found this link
(http://code.google.com/edu/language
On Jul 12, 4:20 pm, Hrvoje Niksic wrote:
> dhruvbird writes:
> > No, I meant x.append(4)
> > Except that I want to accomplish it using slices.
>
> > (I can do it as x[lex(x):] = [item_to_append] but is there any other
> > way?)
>
> It seems that you've found a way to do so, so why do you need ano
Stephen:
I'm not adverse to being able to do that, but the number of times that I've
wanted to do that is greatly outweighed by the number of times I've had to
pass a function "(somestring,)" or call "if isinstance(foo, basestring):
..." to avoid producing a bug. The more abstract and adaptive th
dhruvbird writes:
> No, I meant x.append(4)
> Except that I want to accomplish it using slices.
>
> (I can do it as x[lex(x):] = [item_to_append] but is there any other
> way?)
It seems that you've found a way to do so, so why do you need another
way? Are you after elegance? Efficiency? Brevi
On Jul 12, 5:30 am, News123 wrote:
> dhruvbird wrote:
>
> > On a side note, is there any other way to append to a list using
> > slices (apart from the one below):
> > x[len(x):len(x)] = [item to append]
>
> dy you mean
> x.extend([1,2,3])
No, I meant x.append(4)
Except that I want to accomplish
On Sun, Jul 11, 2010 at 10:03 PM, Nathan Rice
wrote:
> Yeah, I long ago filed the in place place in the same folder as
> all() returning True for an empty iterable
If you weren't taught about vacuous truth (or even identity elements)
in Discrete Mathematics, someone fscked up. Said behavior is t
On 7/11/10 10:03 PM, Nathan Rice wrote:
> Yeah, I long ago filed the in place place in the same folder as
> strings-as-sequences, all() returning True for an empty iterable and any
> returning True rather than the thing which triggered it.
You know, the latter two I can see an argument for, and co
Yeah, I long ago filed the in place place in the same folder as
strings-as-sequences, all() returning True for an empty iterable and any
returning True rather than the thing which triggered it. Almost always
annoying and worked around, but that's the price you pay for the other nice
stuff :) It j
On Jul 11, 8:59 am, dhruvbird wrote:
> Why doesn't python's list append() method return the list itself? For
> that matter, even the reverse() and sort() methods?
Because Guido thinks that having those methods return None is the best
way to communicate that the underlying object
dhruvbird wrote:
>
> On a side note, is there any other way to append to a list using
> slices (apart from the one below):
> x[len(x):len(x)] = [item to append]
dy you mean
x.extend([1,2,3])
?
--
http://mail.python.org/mailman/listinfo/python-list
On Sun, 11 Jul 2010 08:59:06 -0700, dhruvbird wrote:
> Why doesn't python's list append() method return the list itself? For
> that matter, even the reverse() and sort() methods? I found this link
> (http://code.google.com/edu/languages/google-python- class/lists.html)
> wh
On Jul 11, 9:19 pm, Thomas Jollans wrote:
> On 07/11/2010 05:59 PM, dhruvbird wrote:
>
> > Why doesn't python's list append() method return the list itself? For
> > that matter, even the reverse() and sort() methods?
> > I found this link (http://code.goog
Thomas Jollans wrote:
On 07/11/2010 05:59 PM, dhruvbird wrote:
Why doesn't python's list append() method return the list itself? For
that matter, even the reverse() and sort() methods?
I found this link (http://code.google.com/edu/languages/google-python-
class/lists.html) which sug
On Sun, 11 Jul 2010 08:59:06 -0700 (PDT)
dhruvbird wrote:
> Why doesn't python's list append() method return the list itself? For
> that matter, even the reverse() and sort() methods?
> I found this link (http://code.google.com/edu/languages/google-python-
> class/lists.htm
On 07/11/2010 06:28 PM, Nathan Rice wrote:
> Do list(reversed(list(reversed([1, 2, 3, 4])) + [[]]))
>
> Though TBH sometimes get annoyed at this behavior myself. There are a
> lot of people who are very vocal in support of returning none, and it
> makes sense in some ways. Since reversed returns
Do list(reversed(list(reversed([1, 2, 3, 4])) + [[]]))
Though TBH sometimes get annoyed at this behavior myself. There are a lot
of people who are very vocal in support of returning none, and it makes
sense in some ways. Since reversed returns an iterator though, it makes
this code horrible and
On 07/11/2010 05:59 PM, dhruvbird wrote:
> Why doesn't python's list append() method return the list itself? For
> that matter, even the reverse() and sort() methods?
> I found this link (http://code.google.com/edu/languages/google-python-
> class/lists.html) which suggest
Why doesn't python's list append() method return the list itself? For
that matter, even the reverse() and sort() methods?
I found this link (http://code.google.com/edu/languages/google-python-
class/lists.html) which suggests that this is done to make sure that
the programmer understand
En Wed, 31 Dec 2008 06:34:48 -0200, Steven D'Aprano
escribió:
Each time you are appending to the list, you append a tuple:
((i, j), sim)
where sim is a float and i and j are ints. How much memory does each of
those take?
sys.getsizeof( ((0, 1), 1.1) )
32
(On Windows, 32 bits, I get 36)
[BON]:
> above sim is floating type.
> s.append is totally coducted 60,494,500 times.
> but this code raise MemoryError.
>
> My computer has 4G RAM.
> i think it's enough. but it doesn't...
Try creating it in a more clean way, here an array of doubles:
>>> from array import array
>>> a = array("d
On Tue, 30 Dec 2008 22:02:49 -0800, [BON] wrote:
> ==
> s=[]
> for i in range(11000-1):
> for j in range(i+1, 11000):
>
> s.append(((i,j),sim))
> ==
> above sim is floating type.
> s.append is totally coducted 60,494,500 times. but t
[BON] ha scritto:
==
s=[]
for i in range(11000-1):
for j in range(i+1, 11000):
s.append(((i,j),sim))
==
above sim is floating type.
s.append is totally coducted 60,494,500 times.
but this code raise MemoryError.
My computer has
On Wed, Dec 31, 2008 at 4:17 PM, James Mills
wrote:
> I have no idea how many bytes of memory
> storing each element of a list consumes
> let alone each float object, but I assure you
> it's not going to be anywhere near that of
> 60494500 4-bytes spaces (do floats in C
> normally consume 4 bytes)
> but this code raise also MemoryError.
>
> How can i resolve this problem?
> please, help...
>
> Regards,
> --
> View this message in context:
> http://www.nabble.com/MemoryError-when-list-append...-plz-help-tp21227745p21227745.html
> Sent from the Python -
in context:
http://www.nabble.com/MemoryError-when-list-append...-plz-help-tp21227745p21227745.html
Sent from the Python - python-list mailing list archive at Nabble.com.
--
http://mail.python.org/mailman/listinfo/python-list
Rob E wrote:
> On Sat, 15 Sep 2007 03:25:27 +, mouseit wrote:
>
>> I'm trying to add an element to a list which is a property of an
>> object, stored in an array. When I append to one element, all of the
>> lists are appended!
>>
>> Example Code:
>>
>> class Test:
>> array = []
>>
>> myTes
On Sat, 15 Sep 2007 03:25:27 +, mouseit wrote:
> I'm trying to add an element to a list which is a property of an
> object, stored in an array. When I append to one element, all of the
> lists are appended!
>
> Example Code:
>
> class Test:
> array = []
>
> myTests = [Test() , Test() ,
On Sep 14, 11:42 pm, Stephen <[EMAIL PROTECTED]> wrote:
> In your code, "array" is a class attribute, so it is shared among all
> instances. You need to use the __init__ method to define instance
> (data) attributes instead:
>
> def __init__(self):
> self.array = []
>
> On Sep 14, 11:25 pm, mou
In your code, "array" is a class attribute, so it is shared among all
instances. You need to use the __init__ method to define instance
(data) attributes instead:
def __init__(self):
self.array = []
On Sep 14, 11:25 pm, mouseit <[EMAIL PROTECTED]> wrote:
> I'm trying to add an element to a li
I'm trying to add an element to a list which is a property of an
object, stored in an array. When I append to one element, all of the
lists are appended!
Example Code:
class Test:
array = []
myTests = [Test() , Test() , Test()]
print len(myTests[1].array)
myTests[0].array.append( 5 )
print l
42 matches
Mail list logo