Re: Arrays/List, filters, Pytho, Ruby

2011-02-14 Thread LL.Snark
On 12/02/2011 04:49, Terry Reedy wrote: On 2/11/2011 4:24 PM, LL.Snark wrote: Hi, I'm looking for a pythonic way to translate this short Ruby code : t=[6,7,8,6,7,9,8,4,3,6,7] i=t.index {|x| x What does Ruby do if there is no such element? For Python, the answer should be either None or Value

Re: Arrays/List, filters, Pytho, Ruby

2011-02-12 Thread Arnaud Delobelle
Arnaud Delobelle writes: > "LL.Snark" writes: > >> Hi, >> >> I'm looking for a pythonic way to translate this short Ruby code : >> t=[6,7,8,6,7,9,8,4,3,6,7] >> i=t.index {|x| x> > > In Python3: > t = [6,7,8,6,7,9,8,4,3,6,7] next(filter(t[0].__gt__, t)) > 4 Oops! I realised my mistake

Re: Arrays/List, filters, Pytho, Ruby

2011-02-12 Thread Arnaud Delobelle
"LL.Snark" writes: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x In Python3: >>> t = [6,7,8,6,7,9,8,4,3,6,7] >>> next(filter(t[0].__gt__, t)) 4 -- Arnaud -- http://mail.python.org/mailman/listinfo/python-list

Re: Arrays/List, filters, Pytho, Ruby

2011-02-12 Thread DouhetSukd
On Feb 11, 1:24 pm, "LL.Snark" wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x > If you don't know Ruby, the second line means : > What is the index, in array t, of the first element x such that x > If can write it

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Bruno Piguet
On 11 fév, 22:24, "LL.Snark" wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x1000), "not found") or next((i for i, x in enumerate(t) if x>1000), None) or whatever matches your needs. Note that if you use the second o

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Terry Reedy
On 2/11/2011 4:24 PM, LL.Snark wrote: Hi, I'm looking for a pythonic way to translate this short Ruby code : t=[6,7,8,6,7,9,8,4,3,6,7] i=t.index {|x| x What does Ruby do if there is no such element? For Python, the answer should be either None or ValueError. If can write it in python several

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread LL.Snark
On 11/02/2011 22:24, LL.Snark wrote: Hi, I'm looking for a pythonic way to translate this short Ruby code : t=[6,7,8,6,7,9,8,4,3,6,7] i=t.index {|x| x=t[0] : i+=1 ... not pythonic I think... Or : t=[6,7,8,6,7,9,8,4,3,6,7] i=[j for j in range(len(t)) if t[j] Thx for your answers. May I add s

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Jon Clements
On Feb 11, 9:24 pm, "LL.Snark" wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x > If you don't know Ruby, the second line means : > What is the index, in array t, of the first element x such that x > If can write it

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Paul Rubin
"LL.Snark" writes: > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x=t[0], t).next() Note the above can throw an exception if no suitable element is found. t=[6,7,8,6,7,9,8,4,3,6,7] i=[j for j in range(len(t)) if t[j]http

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 1:51 PM, Dan Stromberg wrote: > On Fri, Feb 11, 2011 at 1:43 PM, André Roberge > wrote: >> On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: >>> Hi, >>> >>> I'm looking for a pythonic way to translate this short Ruby code : >>> t=[6,7,8,6,7,9,8,4,3,6,7] >>> i

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Josh Benner
On Fri, Feb 11, 2011 at 1:51 PM, Dan Stromberg wrote: > On Fri, Feb 11, 2011 at 1:43 PM, André Roberge > wrote: > > On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: > >> Hi, > >> > >> I'm looking for a pythonic way to translate this short Ruby code : > >> t=[6,7,8,6,7,9,8,4,3,6,7]

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Ian
On Feb 11, 2:24 pm, "LL.Snark" wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| xhttp://mail.python.org/mailman/listinfo/python-list

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Dan Stromberg
On Fri, Feb 11, 2011 at 1:43 PM, André Roberge wrote: > On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: >> Hi, >> >> I'm looking for a pythonic way to translate this short Ruby code : >> t=[6,7,8,6,7,9,8,4,3,6,7] >> i=t.index {|x| x> >> If you don't know Ruby, the second line means

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread Chris Rebert
On Fri, Feb 11, 2011 at 1:24 PM, LL.Snark wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x > If you don't know Ruby, the second line means : > What is the index, in array t, of the first element x such that x > If ca

Re: Arrays/List, filters, Pytho, Ruby

2011-02-11 Thread André Roberge
On Friday, February 11, 2011 5:24:15 PM UTC-4, LL.Snark wrote: > Hi, > > I'm looking for a pythonic way to translate this short Ruby code : > t=[6,7,8,6,7,9,8,4,3,6,7] > i=t.index {|x| x > If you don't know Ruby, the second line means : > What is the index, in array t, of the first element x such

Re: Arrays

2010-11-29 Thread Garland Fulton
At the top of the last post I didn't understand how I was supposed to have my e mail headers or my quotes formatted. I also would like to change the header to my e mail thread. To I appolpgize and thank you for clearing up my thinking. I just got done with a java class and I should have paid mo

Re: Arrays

2010-11-25 Thread Slie
I have an exercise im working on. I have an array of strings, and I would like to take each peace of the array and assign it to a new array so I can iterate over each of those pieces and replace the sting I want then put it back together. I hope that is not too confusing. This is how im trying

Re: Arrays

2010-11-24 Thread Stefan Behnel
Garland Fulton, 24.11.2010 06:55: Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Are arrays immutable? Python has lists and tuples as basic data structures. Tuples are completely immutable, lists are completely mutable. If you want a container

Re: Arrays

2010-11-23 Thread Ian Kelly
On 11/23/2010 10:55 PM, Garland Fulton wrote: Is there a way I can define an Array of and unknown size so I can add and remove to or from it? Do you mean the arrays of the array module, or NumPy arrays, or something else entirely? In the first case, yes; arrays behave more or less like lists

Re: Arrays and CTYPE

2010-09-21 Thread Nobody
On Mon, 20 Sep 2010 15:47:32 -0700, Glenn Pringle wrote: > Ok. I ran into a problem here. I have been dabbling with Python and I > thought that this would be a good exercise but I got stuck. > > I have a DLL and one of the functions(getState) in that DLL returns an > array. If the DLL was writte

Re: Arrays and CTYPE

2010-09-20 Thread Chris Rebert
On Mon, Sep 20, 2010 at 3:47 PM, Glenn Pringle wrote: > Ok. I ran into a problem here. I have been dabbling with Python and I > thought that this would be a good exercise but I got stuck. > > I have a DLL and one of the functions(getState) in that DLL returns an > array. I'm having a hard time get

Re: arrays in python

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 10:03 PM, AggieDan04 wrote: > On Sep 23, 3:02 pm, Simon Forman wrote: >> On Wed, Sep 23, 2009 at 1:14 PM, Rudolf wrote: >> > Can someone tell me how to allocate single and multidimensional arrays >> > in python. I looked online and it says to do the following x = >> > ['1

Re: arrays in python

2009-09-23 Thread AggieDan04
On Sep 23, 3:02 pm, Simon Forman wrote: > On Wed, Sep 23, 2009 at 1:14 PM, Rudolf wrote: > > Can someone tell me how to allocate single and multidimensional arrays > > in python. I looked online and it says to do the following x = > > ['1','2','3','4'] > > > However, I want a much larger array li

Re: arrays in python

2009-09-23 Thread Donn
On Wednesday 23 September 2009 22:12:24 Ethan Furman wrote: > Works great if you want 4,999,999 elements. ;-) Omit the '1' if you > want all five million. Yes. Fenceposts always get me :) And I was just reminded that one can: l=range(500) \d -- home: http://otherwise.relics.co.za/ 2D vector

Re: arrays in python

2009-09-23 Thread Ethan Furman
Donn wrote: On Wednesday 23 September 2009 19:14:20 Rudolf wrote: I want to allocate an array and then populate it using a for loop. You don't need to allocate anything, just use the list or dictionary types. l=[] #empty list for x in range(1,500): l.append(x) \d Works great if you

Re: arrays in python

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 1:22 PM, Donn wrote: > On Wednesday 23 September 2009 19:14:20 Rudolf wrote: >> I want to allocate an array and then populate it >> using a for loop. > You don't need to allocate anything, just use the list or dictionary types. > > l=[] #empty list > for x in range(1,50

Re: arrays in python

2009-09-23 Thread Simon Forman
On Wed, Sep 23, 2009 at 1:14 PM, Rudolf wrote: > Can someone tell me how to allocate single and multidimensional arrays > in python. I looked online and it says to do the following x = > ['1','2','3','4'] > > However, I want a much larger array like a 100 elements, so I cant > possibly do that. I

Re: arrays in python

2009-09-23 Thread Michel Claveau - MVP
Hi! See: http://docs.python.org/tutorial (section 5) @+ -- MCI -- http://mail.python.org/mailman/listinfo/python-list

Re: arrays in python

2009-09-23 Thread Benjamin Kaplan
On Sep 23, 2009, at 1:16 PM, Rudolf wrote: > Can someone tell me how to allocate single and multidimensional arrays > in python. I looked online and it says to do the following x = > ['1','2','3','4'] > > However, I want a much larger array like a 100 elements, so I cant > possibly do that. I wan

Re: arrays in python

2009-09-23 Thread Donn
On Wednesday 23 September 2009 19:14:20 Rudolf wrote: > I want to allocate an array and then populate it > using a for loop. You don't need to allocate anything, just use the list or dictionary types. l=[] #empty list for x in range(1,500): l.append(x) \d -- http://mail.python.org/mailman/

Re: arrays

2008-05-19 Thread Robert Kern
Gary Herron wrote: 1. Why have you flooded this news group with three identical copies of a question under three different subject? This is a (mild) bit of abuse of the newsgroup. One copy with a reasonable subject line is enough. If you look at the dates, they are a few days old. I imagine

Re: arrays

2008-05-19 Thread Gary Herron
Marlin Rowley wrote: All: Say I have an array: a = ([''],['']) How do I make it so that I now have: starting with first element (a[0]) new_arr[0] = 'r' new_arr[1] = 'g' new_arr[2] = 'b' new_arr[3] = 'a' new_arr[4] = 'r' . continuing "through" a[1] wi

Re: arrays in lists

2007-12-17 Thread Robert Kern
Rafael Sachetto wrote: > No problem here too. > Using python 2.5 on Ubuntu Gutsy and the newest NumPy Okay, I just checked with Travis and we do allow 1-element arrays to have a truth value because it is unambiguous whereas n-element arrays are ambiguous. Regardless, *in general* one cannot use l

Re: arrays in lists

2007-12-17 Thread Robert Kern
Rafael Sachetto wrote: > No problem here too. > Using python 2.5 on Ubuntu Gutsy and the newest NumPy That's a bug, then. It should fail. It looks like we're not raising the exception when there is only one element. -- Robert Kern "I have come to believe that the whole world is an enigma, a har

Re: arrays in lists

2007-12-17 Thread Rafael Sachetto
No problem here too. Using python 2.5 on Ubuntu Gutsy and the newest NumPy 2007/12/17, Robert Kern <[EMAIL PROTECTED]>: > Peter Stahlir wrote: > > Hi! > > > > I have a list of arrays and want to find an array with list.index(x). > > Is that possible. I get an > > ValueError: The truth value of an

Re: arrays in lists

2007-12-17 Thread Robert Kern
Peter Stahlir wrote: > Hi! > > I have a list of arrays and want to find an array with list.index(x). > Is that possible. I get an > ValueError: The truth value of an array with more than one element is > ambiguous. Use a.any() or a.all() > > > For example: > from numpy import array > a = array([

Re: arrays in lists

2007-12-17 Thread bcroq
On 17 déc, 14:05, "Peter Stahlir" <[EMAIL PROTECTED]> wrote: > For example: > from numpy import array > a = array([1]) > b = array([2]) > c = [a,b] > d = c.index(a) No problem here, Python 2.4.4 -- http://mail.python.org/mailman/listinfo/python-list

Re: Arrays

2007-11-14 Thread Steven D'Aprano
On Tue, 13 Nov 2007 22:31:57 -0200, Jorge Godoy wrote: > Steven D'Aprano wrote: > >> "The only intuitive interface is the nipple. After that, it's all >> learned." -- Bruce Ediger on user interfaces. > > And after we learn its other "uses", not even the nipple is so easy... > Who haven't hear

Re: Arrays

2007-11-14 Thread Steven D'Aprano
On Tue, 13 Nov 2007 20:25:07 -0500, Gordon C wrote: > OK Steve, But why do we say "from array import array" and NOT "from > math import math"? Why the difference in syntax? It isn't different syntax. The difference is that there is a function "array" (technically, a type rather than a function

Re: Arrays

2007-11-14 Thread cokofreedom
On Nov 14, 3:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Modules contain objects. When you want to import a specific set of > objects contained in a module into the local namespace, you use: > from import > For example: > from math import sqrt > from math import sin, cos > > If

Re: Arrays

2007-11-13 Thread [EMAIL PROTECTED]
Modules contain objects. When you want to import a specific set of objects contained in a module into the local namespace, you use: from import For example: from math import sqrt from math import sin, cos If you want to import everything from a module, use: from import * For example:

Re: Arrays

2007-11-13 Thread Gordon C
OK Steve, But why do we say "from array import array" and NOT "from math import math"? Why the difference in syntax? Gord "Steven D'Aprano" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Tue, 13 Nov 2007 11:26:28 -0500, Gordon C wrote: > >> OK, thanks to all. The key statement

Re: Arrays

2007-11-13 Thread Jorge Godoy
Steven D'Aprano wrote: > "The only intuitive interface is the nipple. After that, it's all > learned." -- Bruce Ediger on user interfaces. And after we learn its other "uses", not even the nipple is so easy... Who haven't heard (or said, if you're a woman) "Don't bite it like that, it hurts!"?

Re: Arrays

2007-11-13 Thread Steven D'Aprano
On Tue, 13 Nov 2007 11:26:28 -0500, Gordon C wrote: > OK, thanks to all. The key statement is "from array import array" which > is not exactly intuitive! "The only intuitive interface is the nipple. After that, it's all learned." -- Bruce Ediger on user interfaces. Once you've been using Pyt

Re: Arrays

2007-11-13 Thread Chris Mellon
On Nov 13, 2007 10:26 AM, Gordon C <[EMAIL PROTECTED]> wrote: > OK, thanks to all. The key statement is "from array import array" which is > not exactly intuitive! > Gord > It becomes intuitive when you learn Python, which is what you're reading the tutorial for, and it's why the tutorial shows yo

Re: Arrays

2007-11-13 Thread Gordon C
OK, thanks to all. The key statement is "from array import array" which is not exactly intuitive! Gord "John Machin" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > Bernard wrote: >> On 12 nov, 20:19, "Gordon C" <[EMAIL PROTECTED]> wrote: >> > Absolute newbie here. In spite of th

Re: Arrays

2007-11-13 Thread John Machin
On Nov 13, 8:36 pm, "Simon Brunning" <[EMAIL PROTECTED]> wrote: > On Nov 13, 2007 6:58 AM, John Machin <[EMAIL PROTECTED]> wrote: > > > Hey Bernard, read Gordon's message carefully; he's asking about > > arrays, not lists. > > Chances are a list is exactly what the OP wants. > Chances are a list i

Re: Arrays

2007-11-13 Thread Simon Brunning
On Nov 13, 2007 6:58 AM, John Machin <[EMAIL PROTECTED]> wrote: > Hey Bernard, read Gordon's message carefully; he's asking about > arrays, not lists. Chances are a list is exactly what the OP wants. -- Cheers, Simon B. [EMAIL PROTECTED] http://www.brunningonline.net/simon/blog/ GTalk: simon.bru

Re: Arrays

2007-11-12 Thread John Machin
Bernard wrote: > On 12 nov, 20:19, "Gordon C" <[EMAIL PROTECTED]> wrote: > > Absolute newbie here. In spite of the Python Software Foundation tutorial's > > (http://www.python.org/doc/current/tut/tut.html) use of the array > > declaration > > array(type[,initializer]), the Python interpreter doe

Re: Arrays

2007-11-12 Thread Bernard
On 12 nov, 20:19, "Gordon C" <[EMAIL PROTECTED]> wrote: > Absolute newbie here. In spite of the Python Software Foundation tutorial's > (http://www.python.org/doc/current/tut/tut.html) use of the array > declaration > array(type[,initializer]), the Python interpreter does NOT accept the word > ar

RE: Arrays, Got Me Confused

2007-04-13 Thread Robert Rawlins - Think Blue
olden Sent: 13 April 2007 14:03 Cc: [EMAIL PROTECTED] Subject: Re: Arrays, Got Me Confused Robert Rawlins - Think Blue wrote: > Hello Guys, > > Wider fragments of code don't really exists at this moment in time :-D this > is just a bit of a 'tester' class for me to get

RE: Arrays, Got Me Confused

2007-04-13 Thread Carsten Haese
On Fri, 2007-04-13 at 13:50 +0100, Robert Rawlins - Think Blue wrote: > Hello Guys, > > Wider fragments of code don't really exists at this moment in time :-D this > is just a bit of a 'tester' class for me to get used to the methods. > Basically I'm trying to create a class that contains an array

Re: Arrays, Got Me Confused

2007-04-13 Thread Richard Brodie
"Robert Rawlins - Think Blue" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Wider fragments of code don't really exists at this moment in time No but specifying the problem too narrowly tends to get you an unidiomatic solution. > Basically I'm trying to create a class that conta

Re: Arrays, Got Me Confused

2007-04-13 Thread Tim Golden
Robert Rawlins - Think Blue wrote: > Hello Guys, > > Wider fragments of code don't really exists at this moment in time :-D this > is just a bit of a 'tester' class for me to get used to the methods. > Basically I'm trying to create a class that contains an array of MAC > address, these look somet

RE: Arrays, Got Me Confused

2007-04-13 Thread Robert Rawlins - Think Blue
inciples are the same, but the languages I'm used to are more robust and vague so I don't have to define what type of data i'm storing the array and things. Thanks guys, Rob -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tim Golden Sent

Re: Arrays, Got Me Confused

2007-04-13 Thread Tim Golden
Michael Bentley wrote: > > On Apr 13, 2007, at 7:04 AM, Robert Rawlins - Think Blue wrote: >> #!/usr/bin/python >> >> # Filename: Firewall.py >> class Firewall: >>def __init__(self): >> >> Self.FireArray = array(c) >> >> p = Firewall() >> >> print p >> Throws: >> >> >> >> Tra

Re: Arrays, Got Me Confused

2007-04-13 Thread rishi pathak
HI, You will have to import Numeric module Add from Numeric import * to the script For the second question: Suppose you wrote the code for your class in firewall.py and your main script is main.py Put the file firewall.py in the directory where you have main.py Then in main.py do : import firewall

Re: Arrays, Got Me Confused

2007-04-13 Thread Michael Bentley
On Apr 13, 2007, at 7:04 AM, Robert Rawlins - Think Blue wrote: #!/usr/bin/python # Filename: Firewall.py class Firewall: def __init__(self): Self.FireArray = array(c) p = Firewall() print p Throws: Traceback (most recent call last): File "./firewall.p

Re: Arrays? (Or lists if you prefer)

2006-10-28 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Paul McGuire wrote: >> As an example of using pyparsing, I chose a simple text adventure >> application, and had to create a 2-D grid of rooms. The presentation >> materials are online at http://www.python.org/pycon/2006/papers/4/, and

Re: Arrays? (Or lists if you prefer)

2006-10-23 Thread [EMAIL PROTECTED]
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > Interesting. Could I do . . . let's say > > > > b = [range(range(3)] > > > > for a three-dimensional array? > > >>> [range(range(3))] > Traceback (most recent call last): >File "", line 1, in > TypeError: range() integer end argument expe

Re: Arrays? (Or lists if you prefer)

2006-10-23 Thread Hendrik van Rooyen
From: <[EMAIL PROTECTED]> wrote: 8<--- > So: > Way to do SIMPLE array, either internally or externally, with Python, > please. to help you see it - here is a simple 3 row by 3 column list: myarray = [[1,2,3],[4,5,6],[7,8,9]] the first "row" is myarray[0] - ie

Re: Arrays? (Or lists if you prefer)

2006-10-23 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > Interesting. Could I do . . . let's say > > b = [range(range(3)] > > for a three-dimensional array? >>> [range(range(3))] Traceback (most recent call last): File "", line 1, in TypeError: range() integer end argument expected, got list. if your mail program is e

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > What's the difference between xrange and range? range() creates a list object and fills it in up front, xrange() returns a sequence-like object that generates indexes on demand. for short loops, this difference doesn't really matter. for large loops, or if you usual

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread [EMAIL PROTECTED]
Andrea Griffini wrote: > Neil Cerutti wrote: > > > >>> b =[range(2), range(2)] > > I often happened to use > >b = [[0] * N for i in xrange(N)] > > an approach that can also scale up in dimensions; > for example for a cubic NxNxN matrix: > >b = [[[0] * N for i in xrange(N)] >

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread [EMAIL PROTECTED]
Niel Cerutti wrote: >Just build it up bit by bit, or build it all at once >using range() and then fill it in afterwards. >>>> b =[range(2), range(2)] >>>> b >[0, 1], [0, 1]] >>>> b[0][1] = "OK." >>>> b >[0, 'OK.'], [0, 1]] Interesting. Could I do . . . let's say b = [rang

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Andrea Griffini
Neil Cerutti wrote: > >>> b =[range(2), range(2)] I often happened to use b = [[0] * N for i in xrange(N)] an approach that can also scale up in dimensions; for example for a cubic NxNxN matrix: b = [[[0] * N for i in xrange(N)] for j in xrange(N)] Andrea -- htt

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Pythonic lists are everything I want in a one dimensional array . . . > but I'm trying to do a text adventure and simplify the proces by > creating a grid as opposed to a tedious list of rooms this room > connects to. > > Way to do SIM

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Neil Cerutti
On 2006-10-23, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Pythonic lists are everything I want in a one dimensional array > . . . but I'm trying to do a text adventure and simplify the > proces by creating a grid as opposed to a tedious list of rooms > this room connects to. Not to chase you

Re: Arrays? (Or lists if you prefer)

2006-10-22 Thread Paul Rubin
"[EMAIL PROTECTED]" <[EMAIL PROTECTED]> writes: > Way to do SIMPLE array, either internally or externally, with Python, Maybe you want to use a dictionary: a = {} a[(3,5)] = 2 -- http://mail.python.org/mailman/listinfo/python-list

Re: arrays, even, roundup, odd round down ?

2006-05-17 Thread Serge Orlov
Lance Hoffmeyer wrote: > So, I have using the following to grab numbers from MS Word. I discovered > that that there is a "special" > rule being used for rounding. > > If a ??.5 is even the number is to rounded down (20.5 = 20) > if a ??.5 is odd the number is to rounded up (21.5 = 22) > > Brands

Re: arrays, even, roundup, odd round down ?

2006-05-16 Thread Ben Finney
Lance Hoffmeyer <[EMAIL PROTECTED]> writes: > So, I have using the following to grab numbers from MS Word. I > discovered that that there is a "special" rule being used for > rounding. > > If a ??.5 is even the number is to rounded down (20.5 = 20) > if a ??.5 is odd the number is to rounded up

Re: arrays in python

2006-02-10 Thread plahey
> Oh, don't tell me, I love playing guessing games! Don't you mean "No no... don't tell me. I'm keen to guess." Sorry, I couldn't resist... :-) (for those who just went huh?, see http://www.aldo.com/sgt/CheeseShoppeSkit.htm) -- http://mail.python.org/mailman/listinfo/python-list

Re: arrays in python

2006-02-10 Thread Steven D'Aprano
On Fri, 10 Feb 2006 17:50:21 -0500, Kermit Rose wrote: > I want to write a program in python using integer arrays. > > I wish to calculate formulas using 200 digit integers. Must the integers have exactly 200 digits? If you multiply one of these 200-digit integers by ten, should it silently ove

Re: arrays in python

2006-02-10 Thread Schüle Daniel
> I want to write a program in python using integer arrays. you can :) > I wish to calculate formulas using 200 digit integers. no problem > I could not find any documentation in python manual about declaring arrays. > > I searched the internet read here http://diveintopython.org/native_dat

Re: arrays in python

2006-02-10 Thread Steve Holden
Kermit Rose wrote: > From: Kermit Rose > Date: 02/10/06 17:36:34 > To: [EMAIL PROTECTED] > Subject: Arrays > > > Hello. > > I want to write a program in python using integer arrays. > > I wish to calculate formulas using 200 digit integers. > > I could not find any documentation in pytho