Re: Python arrays and sting formatting options

2008-10-03 Thread bearophileHUGS
Marc 'BlackJack' Rintsch: > bearophile > while xrange(n) is a bit less easy to > > understand (a generator or generators). I meant "a generator of generators", a typo, sorry. -.- Bye, bearophile -- http://mail.python.org/mailman/listinfo/python-list

Re: Python arrays and sting formatting options

2008-10-03 Thread Steven D'Aprano
I'm not sure if our views are moving closer together or further apart, but here goes... On Thu, 02 Oct 2008 23:49:16 +, Marc 'BlackJack' Rintsch wrote: > On Thu, 02 Oct 2008 14:51:29 +, Steven D'Aprano wrote: > >> On Wed, 01 Oct 2008 10:38:12 +, Marc 'BlackJack' Rintsch wrote: >>

Re: Python arrays and sting formatting options

2008-10-03 Thread Marc 'BlackJack' Rintsch
On Thu, 02 Oct 2008 18:15:59 -0700, bearophileHUGS wrote: > What's a range(n)? A function that returns a list of n items, from 0 to > n. This is easy to understand, while xrange(n) is a bit less easy to > understand (a generator or generators). `xrange()` doesn't return a generator or iterator

Re: Python arrays and sting formatting options

2008-10-02 Thread bearophileHUGS
Steven D'Aprano: > With Python 3.0, GvR had the > opportunity to strip Python of all the features that makes Python easy to > learn, and he didn't. Python still has features that are easy for > newbies, and features that are powerful for experienced coders, and that > friendliness for newbies isn't

Re: Python arrays and sting formatting options

2008-10-02 Thread Marc 'BlackJack' Rintsch
On Thu, 02 Oct 2008 14:51:29 +, Steven D'Aprano wrote: > On Wed, 01 Oct 2008 10:38:12 +, Marc 'BlackJack' Rintsch wrote: > >> Even if newbies don't understand all the details they should be >> introduced to ``with`` right away IMHO. Because if you explain all the >> details, even if they

Re: Python arrays and sting formatting options

2008-10-02 Thread Steven D'Aprano
On Wed, 01 Oct 2008 10:38:12 +, Marc 'BlackJack' Rintsch wrote: >> The first problem with "with" is that it looks like the Pascal "with" >> statement, but acts nothing like it. That may confuse anyone with >> Pascal experience, and there are a lot of us out there. > > But Python is not Pascal

Re: Python arrays and sting formatting options

2008-10-01 Thread Paul Probert
Grant Edwards wrote: > On 2008-09-30, Peter Pearson <[EMAIL PROTECTED]> wrote: >> On Tue, 30 Sep 2008 00:04:18 +0200, Ivan Rebori wrote: >>> 1. Multi dimensional arrays - how do you load them in python >>> For example, if I had: >>> --- >>> 1 2 3 >>> 4 5 6 >>> 7 8 9 >>> >>> 10 11 12 >>> 13 14 1

Re: Python arrays and sting formatting options

2008-10-01 Thread Marc 'BlackJack' Rintsch
On Wed, 01 Oct 2008 09:35:03 +, Steven D'Aprano wrote: > On Wed, 01 Oct 2008 06:58:11 +, Marc 'BlackJack' Rintsch wrote: > >>> I would weaken that claim a tad... I'd say it is "usual" to write >>> something like this: >>> >>> alist = [] >>> for x in some_values: >>> alist.append(some

Re: Python arrays and sting formatting options

2008-10-01 Thread Steven D'Aprano
On Wed, 01 Oct 2008 06:58:11 +, Marc 'BlackJack' Rintsch wrote: >> I would weaken that claim a tad... I'd say it is "usual" to write >> something like this: >> >> alist = [] >> for x in some_values: >> alist.append(something_from_x) >> >> >> but it is not uncommon (at least not in my c

Re: Python arrays and sting formatting options

2008-10-01 Thread Steven D'Aprano
On Tue, 30 Sep 2008 19:44:40 -0500, Grant Edwards wrote: > On 2008-09-30, Steven D'Aprano <[EMAIL PROTECTED]> > wrote: >> On Tue, 30 Sep 2008 10:57:19 -0500, Grant Edwards wrote: >> > How would the python equivalent go ? >>> >>> You would drag yourself out of the 1960s, install numpy, and the

Re: Python arrays and sting formatting options

2008-10-01 Thread Marc 'BlackJack' Rintsch
On Tue, 30 Sep 2008 23:40:22 +, Steven D'Aprano wrote: > On Tue, 30 Sep 2008 14:34:31 +, Marc 'BlackJack' Rintsch wrote: > >> There is no array. The data type is called "list" in Python, so >> `result` is a nested list. And in Python it quite unusual to build >> lists by creating them w

Re: Python arrays and sting formatting options

2008-09-30 Thread Grant Edwards
On 2008-09-30, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Tue, 30 Sep 2008 10:57:19 -0500, Grant Edwards wrote: > How would the python equivalent go ? >> >> You would drag yourself out of the 1960s, install numpy, and >> then do something like this: > > I think that was thoughtlessly rud

Re: Python arrays and sting formatting options

2008-09-30 Thread Gabriel Genellina
En Mon, 29 Sep 2008 19:04:18 -0300, Ivan Reborin <[EMAIL PROTECTED]> escribió: 1. Multi dimensional arrays - how do you load them in python For example, if I had: --- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 --- with "i" being the row number, "j" the column number, and "k" the ..

Re: Python arrays and sting formatting options

2008-09-30 Thread Steven D'Aprano
On Tue, 30 Sep 2008 14:34:31 +, Marc 'BlackJack' Rintsch wrote: > On Tue, 30 Sep 2008 15:42:58 +0200, Ivan Reborin wrote: > >> On 30 Sep 2008 07:07:52 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> >> wrote: >>>= >>>from __future__ import with_statement from functools import partial >>

Re: Python arrays and sting formatting options

2008-09-30 Thread Steven D'Aprano
On Tue, 30 Sep 2008 10:57:19 -0500, Grant Edwards wrote: >>> How would the python equivalent go ? > > You would drag yourself out of the 1960s, install numpy, and then do > something like this: I think that was thoughtlessly rude to somebody who is asking a perfectly reasonable question. --

Re: Python arrays and sting formatting options

2008-09-30 Thread Grant Edwards
On 2008-09-30, Ivan Reborin <[EMAIL PROTECTED]> wrote: > But as I said, got a job that't got to be done, so I'm trying > to figure out how to do array operations as easily as possible > in python, which are necessary for all my calculations. numpy -- Grant Edwards grante

Re: Python arrays and sting formatting options

2008-09-30 Thread Ivan Reborin
On 30 Sep 2008 15:31:59 GMT, Peter Pearson <[EMAIL PROTECTED]> wrote: > >Since you're coming from the FORTRAN world (thank you for >that stroll down Memory Lane), you might be doing scientific >computations, and so might be interested in the SciPy >package (Google scipy), which gives you arrays an

Re: Python arrays and sting formatting options

2008-09-30 Thread Marc 'BlackJack' Rintsch
On Tue, 30 Sep 2008 10:57:19 -0500, Grant Edwards wrote: > On 2008-09-30, Peter Pearson <[EMAIL PROTECTED]> wrote: >> On Tue, 30 Sep 2008 00:04:18 +0200, Ivan Rebori wrote: >>> >>> 1. Multi dimensional arrays - how do you load them in python For >>> example, if I had: >>> --- >>> 1 2 3 >>> 4 5

Re: Python arrays and sting formatting options

2008-09-30 Thread Grant Edwards
On 2008-09-30, Peter Pearson <[EMAIL PROTECTED]> wrote: > On Tue, 30 Sep 2008 00:04:18 +0200, Ivan Rebori wrote: >> >> 1. Multi dimensional arrays - how do you load them in python >> For example, if I had: >> --- >> 1 2 3 >> 4 5 6 >> 7 8 9 >> >> 10 11 12 >> 13 14 15 >> 16 17 18 >> --- >> wi

Re: Python arrays and sting formatting options

2008-09-30 Thread Peter Pearson
On Tue, 30 Sep 2008 00:04:18 +0200, Ivan Rebori wrote: > > 1. Multi dimensional arrays - how do you load them in python > For example, if I had: > --- > 1 2 3 > 4 5 6 > 7 8 9 > > 10 11 12 > 13 14 15 > 16 17 18 > --- > with "i" being the row number, "j" the column number, and "k" the .. > uh

Re: Python arrays and sting formatting options

2008-09-30 Thread Marc 'BlackJack' Rintsch
On Tue, 30 Sep 2008 15:42:58 +0200, Ivan Reborin wrote: > On 30 Sep 2008 07:07:52 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> > wrote: >>= >>from __future__ import with_statement from functools import partial >>from itertools import islice >>from pprint import pprint >> >> >>def read_gro

Re: Python arrays and sting formatting options

2008-09-30 Thread Ivan Reborin
On 30 Sep 2008 07:07:52 GMT, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: Hello Marc, thanks for answering (on both subjects). I understand now the logic which lays behind what you were explaining in the other one. It cleared things quite a bit. >Well, I don't know if this qualifies as equ

Re: Python arrays and sting formatting options

2008-09-30 Thread Aidan
Ivan Reborin wrote: Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For example, if I had: --- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 --- with "i"

Re: Python arrays and sting formatting options

2008-09-30 Thread Marc 'BlackJack' Rintsch
On Tue, 30 Sep 2008 00:04:18 +0200, Ivan Reborin wrote: > 1. Multi dimensional arrays - how do you load them in python For > example, if I had: > --- > 1 2 3 > 4 5 6 > 7 8 9 > > 10 11 12 > 13 14 15 > 16 17 18 > --- > with "i" being the row number, "j" the column number, and "k" the .. > u

Re: Python arrays and sting formatting options

2008-09-29 Thread Marc 'BlackJack' Rintsch
On Tue, 30 Sep 2008 03:56:03 +0200, Ivan Reborin wrote: > a = 2.01 > b = 123456.789 > c = 1234.0001 > d = 98765.4321 > # same as above except for d > > print (3 * '%12.3f') % (a, b, c) > #this works beautifully > > How to add d at the end but with a different format now, since I've > "used"

Re: Python arrays and sting formatting options

2008-09-29 Thread Chris Rebert
On Mon, Sep 29, 2008 at 6:56 PM, Ivan Reborin <[EMAIL PROTECTED]> wrote: > On Mon, 29 Sep 2008 17:59:40 -0700 (PDT), [EMAIL PROTECTED] > wrote: > > Hello bearophile, thank you for replying. > >>The Python genie grants you that wish. You were almost right: > print (3 * '%12.3f') % (a, b, c) >>

Re: Python arrays and sting formatting options

2008-09-29 Thread Ivan Reborin
On Mon, 29 Sep 2008 17:59:40 -0700 (PDT), [EMAIL PROTECTED] wrote: Hello bearophile, thank you for replying. >The Python genie grants you that wish. You were almost right: print (3 * '%12.3f') % (a, b, c) > 2.000 123456.7891234.000 print 3 * '%12.3f' % (a, b, c) > 2.000

Re: Python arrays and sting formatting options

2008-09-29 Thread bearophileHUGS
Ivan Reborin: > Is there a way to just do something like this (not normal syntax, just > my wishful thinking): > print 3*'%12.3f' %a,b,c > (meaning - use this format for the next 3 real numbers that come > along) The Python genie grants you that wish. You were almost right: >>> a = 2.01 >>> b

Re: Python arrays and sting formatting options

2008-09-29 Thread Ivan Reborin
On Mon, 29 Sep 2008 16:08:28 -0700 (PDT), Mensanator <[EMAIL PROTECTED]> wrote: >> 2. I've read the help on the next one but I just find it difficult >> understanding it. >> I have; >> a=2.01 >> b=123456.789 >> c=1234.0001 >> Hello Mensanator, thank you for answering in such a short time. <

Re: Python arrays and sting formatting options

2008-09-29 Thread Mensanator
On Sep 29, 5:04 pm, Ivan Reborin <[EMAIL PROTECTED]> wrote: > Hello everyone, > > I was wondering if anyone here has a moment of time to help me with 2 > things that have been bugging me. > > 1. Multi dimensional arrays - how do you load them in python > For example, if I had: > --- > 1 2 3 > 4

Python arrays and sting formatting options

2008-09-29 Thread Ivan Reborin
Hello everyone, I was wondering if anyone here has a moment of time to help me with 2 things that have been bugging me. 1. Multi dimensional arrays - how do you load them in python For example, if I had: --- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 --- with "i" being the row number,