Re: Perl's @foo[3,7,1,-1] ?

2009-06-23 Thread Lie Ryan
Jean-Michel Pichavant wrote: Lie Ryan wrote: Jean-Michel Pichavant wrote: snip Maybe I've been a little bit too dictatorial when I was saying that renaming namespaces should be avoided. Sure your way of doing make sense. In fact they're 2 main purposes of having strong coding rules:

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Jean-Michel Pichavant
J. Cliff Dyer wrote: On Wed, 2009-06-17 at 14:13 +0200, Jean-Michel Pichavant wrote: On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np -- Pierre delroth Bourdon delr...@gmail.com Étudiant à l'EPITA / Student at EPITA

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread J. Cliff Dyer
On Mon, 2009-06-22 at 14:57 +0200, Jean-Michel Pichavant wrote: J. Cliff Dyer wrote: On Wed, 2009-06-17 at 14:13 +0200, Jean-Michel Pichavant wrote: On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np -- Pierre

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Jean-Michel Pichavant
J. Cliff Dyer wrote: On Mon, 2009-06-22 at 14:57 +0200, Jean-Michel Pichavant wrote: J. Cliff Dyer wrote: On Wed, 2009-06-17 at 14:13 +0200, Jean-Michel Pichavant wrote: On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange?

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Lie Ryan
Jean-Michel Pichavant wrote: snip Maybe I've been a little bit too dictatorial when I was saying that renaming namespaces should be avoided. Sure your way of doing make sense. In fact they're 2 main purposes of having strong coding rules: 1/ ease the coder's life 2/ ease the reader's life

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Jean-Michel Pichavant
Lie Ryan wrote: Jean-Michel Pichavant wrote: snip Maybe I've been a little bit too dictatorial when I was saying that renaming namespaces should be avoided. Sure your way of doing make sense. In fact they're 2 main purposes of having strong coding rules: 1/ ease the coder's life 2/ ease

Re: Perl's @foo[3,7,1,-1] ?

2009-06-22 Thread Robert Kern
On 2009-06-22 13:31, Jean-Michel Pichavant wrote: Moreover, writing numpy instead of np is not harder for the coder than switching mentally from np to numpy for the reader. It's just about who you want to make the life easier, the coder or the reader ? shrug It depends on the audience. For

Re: Perl's @foo[3,7,1,-1] ?

2009-06-18 Thread Hyuga
On Jun 13, 6:22 pm, Brian Quinlan br...@sweetapp.com wrote: MRAB wrote: Brian Quinlan wrote: kj wrote: In slrnh37t2p.63e.n...@irishsea.home.craig-wood.com Nick Craig-Wood n...@craig-wood.com writes: However I can't think of the last time I wanted to do this - array elements having

Re: Perl's @foo[3,7,1,-1] ?

2009-06-17 Thread Jean-Michel Pichavant
On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np -- Pierre delroth Bourdon delr...@gmail.com Étudiant à l'EPITA / Student at EPITA Perfect example of why renaming namespaces should be done only when absolutely required, that is, almost

Re: Perl's @foo[3,7,1,-1] ?

2009-06-17 Thread Scott David Daniels
Jean-Michel Pichavant wrote: On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np Perfect example of why renaming namespaces should be done only when absolutely required, that is, almost never. Jean-Michel Actually, np. is quite commonly used in

Re: Perl's @foo[3,7,1,-1] ?

2009-06-17 Thread J. Cliff Dyer
On Wed, 2009-06-17 at 14:13 +0200, Jean-Michel Pichavant wrote: On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np -- Pierre delroth Bourdon delr...@gmail.com Étudiant à l'EPITA / Student at EPITA Perfect example of why renaming

Re: Perl's @foo[3,7,1,-1] ?

2009-06-17 Thread Alan G Isaac
On 6/17/2009 4:03 PM J. Cliff Dyer apparently wrote: example code should always include relevant imports. Agreed. It was a cut and paste failure. Apologies. Alan Isaac -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl's @foo[3,7,1,-1] ?

2009-06-16 Thread Alan G Isaac
On 6/13/2009 2:11 PM kj apparently wrote: Switching from Perl here, and having a hard time letting go... Suppose I have an array foo, and that I'm interested in the 4th, 8th, second, and last element in that array. In Perl I could write: my @wanted = @foo[3, 7, 1, -1]; a =

Re: Perl's @foo[3,7,1,-1] ?

2009-06-16 Thread Steven D'Aprano
On Wed, 17 Jun 2009 01:50:55 +, Alan G Isaac wrote: On 6/13/2009 2:11 PM kj apparently wrote: Switching from Perl here, and having a hard time letting go... Suppose I have an array foo, and that I'm interested in the 4th, 8th, second, and last element in that array. In Perl I could

Re: Perl's @foo[3,7,1,-1] ?

2009-06-16 Thread Pierre Bourdon
On Wed, Jun 17, 2009 at 04:14, Steven D'Aprano wrote: What's np.arange? import numpy as np -- Pierre delroth Bourdon delr...@gmail.com Étudiant à l'EPITA / Student at EPITA -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl's @foo[3,7,1,-1] ?

2009-06-15 Thread J. Cliff Dyer
On Sun, 2009-06-14 at 23:01 +1000, Steven D'Aprano wrote: Write a helper function: def getitems(L, *indexes): if len(indexes) == 1: indexes = indexes[0] return [L[i] for i in indexes] Whoops! Your example is broken: cars = ['Ford', 'Toyota', 'Edsel'] getitems(cars, 1)

Re: Perl's @foo[3,7,1,-1] ?

2009-06-14 Thread Vito De Tullio
Jack Diederich wrote: the square brackets always expect an int or a slice. true only for lists :) In [1]: mydict = {} In [2]: mydict[1,2,3] = 'hi' In [3]: print mydict[1,2,3] -- print(mydict[1,2,3]) hi -- By ZeD -- http://mail.python.org/mailman/listinfo/python-list

Re: Perl's @foo[3,7,1,-1] ?

2009-06-14 Thread Lie Ryan
Piet van Oostrum wrote: kj no.em...@please.post (k) wrote: k Switching from Perl here, and having a hard time letting go... k Suppose I have an array foo, and that I'm interested in the 4th, 8th, k second, and last element in that array. In Perl I could write: k my @wanted = @foo[3,

Re: Perl's @foo[3,7,1,-1] ?

2009-06-14 Thread Steven D'Aprano
kj wrote: OK, I see: if Python allowed foo[3,7,1,-1], then foo[3] would be ambiguous: does it mean the fourth element of foo, or the tuple consisting of this element alone? I suppose that's good enough reason to veto this idea... There's nothing ambiguous about it. obj.__getitem__(x)

Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread kj
Switching from Perl here, and having a hard time letting go... Suppose I have an array foo, and that I'm interested in the 4th, 8th, second, and last element in that array. In Perl I could write: my @wanted = @foo[3, 7, 1, -1]; I was a bit surprised when I got this in Python: wanted =

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Jack Diederich
On Sat, Jun 13, 2009 at 2:11 PM, kjno.em...@please.post wrote: Switching from Perl here, and having a hard time letting go... Suppose I have an array foo, and that I'm interested in the 4th, 8th, second, and last element in that array.  In Perl I could write:  my @wanted = @foo[3, 7, 1,

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Nick Craig-Wood
kj no.em...@please.post wrote: Switching from Perl here, and having a hard time letting go... Suppose I have an array foo, and that I'm interested in the 4th, 8th, second, and last element in that array. In Perl I could write: my @wanted = @foo[3, 7, 1, -1]; I was a bit

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Brian Quinlan
kj wrote: Switching from Perl here, and having a hard time letting go... Suppose I have an array foo, and that I'm interested in the 4th, 8th, second, and last element in that array. In Perl I could write: my @wanted = @foo[3, 7, 1, -1]; Could you explain your use case? It could be that

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Arnaud Delobelle
kj no.em...@please.post writes: Switching from Perl here, and having a hard time letting go... Suppose I have an array foo, and that I'm interested in the 4th, 8th, second, and last element in that array. In Perl I could write: my @wanted = @foo[3, 7, 1, -1]; I was a bit surprised when

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread kj
In mailman.1531.1244920680.8015.python-l...@python.org Jack Diederich jackd...@gmail.com writes: There is only so much room in the syntax for common cases before you end up with ... perl (no offense intended, I'm a perl monk[1]). The Python grammar isn't as context sensitive or irregular as

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread kj
In slrnh37t2p.63e.n...@irishsea.home.craig-wood.com Nick Craig-Wood n...@craig-wood.com writes: However I can't think of the last time I wanted to do this - array elements having individual purposes are usually a sign that you should be using a different data structure. In the case I was

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Brian Quinlan
kj wrote: In slrnh37t2p.63e.n...@irishsea.home.craig-wood.com Nick Craig-Wood n...@craig-wood.com writes: However I can't think of the last time I wanted to do this - array elements having individual purposes are usually a sign that you should be using a different data structure. In the

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread MRAB
Brian Quinlan wrote: kj wrote: In slrnh37t2p.63e.n...@irishsea.home.craig-wood.com Nick Craig-Wood n...@craig-wood.com writes: However I can't think of the last time I wanted to do this - array elements having individual purposes are usually a sign that you should be using a different data

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Brian Quinlan
MRAB wrote: Brian Quinlan wrote: kj wrote: In slrnh37t2p.63e.n...@irishsea.home.craig-wood.com Nick Craig-Wood n...@craig-wood.com writes: However I can't think of the last time I wanted to do this - array elements having individual purposes are usually a sign that you should be using a

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread kj
In h113qm$pl...@reader1.panix.com kj no.em...@please.post writes: OK, I see: if Python allowed foo[3,7,1,-1], then foo[3] would be ambiguous: does it mean the fourth element of foo, or the tuple consisting of this element alone? I suppose that's good enough reason to veto this idea... Hmmm,

Re: Perl's @foo[3,7,1,-1] ?

2009-06-13 Thread Piet van Oostrum
kj no.em...@please.post (k) wrote: k Switching from Perl here, and having a hard time letting go... k Suppose I have an array foo, and that I'm interested in the 4th, 8th, k second, and last element in that array. In Perl I could write: k my @wanted = @foo[3, 7, 1, -1]; k I was a bit